コード例 #1
0
        public void Notify(List<IConsumerMessage> msgs, ConsumerContext context, ProducerConsumer<Action> executorService, IPipeline<object> pipeline)
        {
            foreach (IConsumerMessage msg in msgs)
            {
                NackDelayedBrokerConsumerMessage nackDelayedMsg = new NackDelayedBrokerConsumerMessage((BrokerConsumerMessage)msg);
                List<IConsumerMessage> singleMsg = new List<IConsumerMessage>();
                singleMsg.Add(nackDelayedMsg);

                int retries = 0;
                while (true)
                {
                    pipeline.Put(new Pair<ConsumerContext, List<IConsumerMessage>>(context, singleMsg));

                    if (nackDelayedMsg.BaseConsumerMessage.Status == MessageStatus.FAIL)
                    {
                        // reset status to enable reconsume or nack
                        nackDelayedMsg.BaseConsumerMessage.ResetStatus();
                        if (retries < m_retryPolicy.GetRetryTimes())
                        {
                            Sleep(m_retryPolicy.NextScheduleTimeMillis(retries, 0));
                            retries++;
                        }
                        else
                        {
                            msg.Nack();
                            break;
                        }
                    }
                    else
                    {
                        msg.Ack();
                        break;
                    }
                }
            }
        }
コード例 #2
0
 public void Notify(List<IConsumerMessage> msgs, ConsumerContext context, ProducerConsumer<Action> executorService, IPipeline<object> pipeline)
 {
     pipeline.Put(new Pair<ConsumerContext, List<IConsumerMessage>>(context, msgs));
 }