Esempio n. 1
0
        public void Consume(Distributed <T> message)
        {
            _pendingMessages.Consumed(message.CorrelationId);

            Action <T> consumer = _getConsumer(message.Payload);

            Interlocked.Increment(ref _inProgress);
            try
            {
                RewriteResponseAddress(message.ResponseAddress);

                consumer(message.Payload);
            }
            finally
            {
                Interlocked.Decrement(ref _inProgress);

                ScheduleUpdate();
                ScheduleWakeUp();

                var disposal = consumer as IDisposable;
                if (disposal != null)
                {
                    disposal.Dispose();
                }
            }
        }
Esempio n. 2
0
        public void Consume(Distributed <TMessage> message)
        {
            _pendingMessages.Consumed(message.CorrelationId);

            Action <TMessage> consumer = _getConsumer(message.Payload);

            Interlocked.Increment(ref _inProgress);
            try
            {
                RewriteResponseAddress(message.ResponseAddress);

                consumer(message.Payload);

                var consumeContext = _bus.MessageContext <Distributed <TMessage> >();

                consumeContext.BaseContext.NotifyConsume(consumeContext, typeof(Worker <TMessage>).ToShortTypeName(),
                                                         message.CorrelationId.ToString());
            }
            finally
            {
                Interlocked.Decrement(ref _inProgress);

                ScheduleUpdate();
                ScheduleWakeUp();

                var disposal = consumer as IDisposable;
                if (disposal != null)
                {
                    disposal.Dispose();
                }
            }
        }
Esempio n. 3
0
        void Handle(IConsumeContext <Distributed <TMessage> > context,
                    Action <IConsumeContext <Distributed <TMessage> > > handler)
        {
            Interlocked.Increment(ref _inProgress);
            try
            {
                _pending.Consumed(context.Message.CorrelationId);

                handler(context);
            }
            finally
            {
                Interlocked.Decrement(ref _inProgress);

                ScheduleUpdate();
            }
            //                RewriteResponseAddress(message.ResponseAddress);
            //              consumeContext.BaseContext.NotifyConsume(consumeContext, typeof (Worker<TMessage>).ToShortTypeName(),
            //                  message.CorrelationId.ToString());
            //                ScheduleUpdate();
            //                ScheduleWakeUp();
        }
Esempio n. 4
0
 public void ConsumingMessage <TMessage>(Distributed <TMessage> message)
 {
     _pendingMessages.Consumed(message.CorrelationId);
 }