Handles all the logic to receive messages from an IInboundTransport in a message loop. Handles success and failure scenarios. Actual message processing is delegated to the IMessageDispatcher.
Наследование: IDisposable
Пример #1
0
        public Processor(string endpoint,
                         int concurrencyLevel,
                         ISubscriptionManager subscriptionManager,
                         ITransportFactory transportFactory,
                         ILoggerFactory loggerFactory,
                         IDependencyResolver resolver)
        {
            this.endpoint            = endpoint;
            this.subscriptionManager = subscriptionManager;
            this.resolver            = resolver;

            this.subscriptions = new HashSet <Subscription>();
            this.registry      = new Dictionary <string, Dictionary <string, IMessageHandler> >();

            this.worker = new MessageWorker(
                transportFactory.CreateInboundTransport(endpoint: endpoint),
                new DiagnosticsDispatcher(this),                 // TODO: build proper pipeline support
                loggerFactory,
                concurrencyLevel);
        }
Пример #2
0
        public void TestConcurrencyLevelIsRespected(int concurrencyLevel, int nMessages, int processingTime)
        {
            var evt = new ManualResetEvent(false);
            
            // TODO: this test isn't testing any behaviour so far.. 
            // just ensuring the worker can cope with high number of messages

            var receiver = SetupReceiver(nMessages);
            var dispatcher = SetupDispatcher(nMessages, processingTime, evt);
            using (var processor = new MessageWorker(receiver, dispatcher, new NullLoggerFactory(), concurrencyLevel))
            {
                processor.Start();

                Task.Delay(TimeSpan.FromMinutes(15)).ContinueWith(t => evt.Set());

                evt.WaitOne();
            }
        }