예제 #1
0
        public MultiQueuedPublisher(
            IBus bus,
            uint queueCount,
            TimeSpan?slowMsgThreshold,
            TimeSpan?slowCmdThreshold)
        {
            this._bus         = bus;
            _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);
            if (queueCount > 0)
            {
                _publishQueue = new MultiQueuedHandler(
                    (int)queueCount,
                    i => new QueuedHandler(new AdHocHandler <IMessage>(bus.Publish)
                                           , nameof(MultiQueuedPublisher)));
                _publishQueue.Start();
            }
        }