Exemplo n.º 1
0
        public Dispatcher(
            string name,
            int queueCount            = 1,
            bool watchSlowMsg         = false,
            TimeSpan?slowMsgThreshold = null,
            TimeSpan?slowCmdThreshold = null)
        {
            var slowMsgThreshold1 = slowMsgThreshold ?? TimeSpan.FromMilliseconds(100);
            var slowCmdThreshold1 = slowCmdThreshold ?? TimeSpan.FromMilliseconds(500);

            _bus             = new InMemoryBus(name, watchSlowMsg, slowMsgThreshold);
            _queuedPublisher = new MultiQueuedPublisher(_bus, queueCount, slowMsgThreshold1, slowCmdThreshold1);
            _handleWrappers  = new Dictionary <Type, object>();
        }
Exemplo n.º 2
0
        protected QueuedSubscriber(IBus bus, bool idempotent = false)
        {
            _externalBus = bus ?? throw new ArgumentNullException(nameof(bus));
            _internalBus = new InMemoryBus("SubscriptionBus");

            if (idempotent)
            {
                _messageQueue = new QueuedHandler(
                    new IdempotentHandler <IMessage>(
                        new AdHocHandler <IMessage>(_internalBus.Publish)
                        ),
                    "SubscriptionQueue");
            }
            else
            {
                _messageQueue = new QueuedHandler(
                    new AdHocHandler <IMessage>(_internalBus.Publish),
                    "SubscriptionQueue");
            }
            _messageQueue.Start();
        }
Exemplo n.º 3
0
        public MultiQueuedPublisher(
            IBus bus,
            int queueCount,
            TimeSpan?slowMsgThreshold,
            TimeSpan?slowCmdThreshold)
        {
            _slowMsgThreshold = slowMsgThreshold;
            _slowCmdThreshold = slowCmdThreshold;
            _timeoutBus       = new InMemoryBus(nameof(_timeoutBus), false);
            _laterService     = new LaterService(_timeoutBus, TimeSource.System);
            _timeoutBus.Subscribe <DelaySendEnvelope>(_laterService);
            _laterService.Start();

            _manager = new CommandManager(bus, _timeoutBus);
            _timeoutBus.Subscribe <AckTimeout>(_manager);
            _timeoutBus.Subscribe <CompletionTimeout>(_manager);

            _publishQueue = new MultiQueuedHandler(
                queueCount,
                i => new QueuedHandler(new AdHocHandler <Message>(bus.Publish)
                                       , nameof(MultiQueuedPublisher)));
            _publishQueue.Start();
        }