Apache.NMS.ActiveMQ.Test.RollbackRedeliveryTest.TestValidateRedeliveryCountOnRollback C# (CSharp) Method

TestValidateRedeliveryCountOnRollback() private method

private TestValidateRedeliveryCountOnRollback ( ) : void
return void
        public void TestValidateRedeliveryCountOnRollback()
        {
            const int numMessages = 1;
            connection.Start();

            PopulateDestination(numMessages, destinationName);

            {
                int received = 0;
                int maxRetries = new RedeliveryPolicy().MaximumRedeliveries;

                while(received < maxRetries)
                {
                    ISession session = connection.CreateSession(AcknowledgementMode.Transactional);
                    IDestination destination = session.GetQueue(destinationName);

                    IMessageConsumer consumer = session.CreateConsumer(destination);
                    ITextMessage msg = (ITextMessage) consumer.Receive(TimeSpan.FromMilliseconds(2000));

                    if(msg != null)
                    {
                        Interlocked.Increment(ref received);
                        Assert.AreEqual(received, msg.Properties.GetLong("NMSXDeliveryCount"),
                                        "redelivery property matches deliveries");
                        session.Rollback();
                    }
                    session.Close();
                }

                ConsumeMessage(maxRetries + 1);
            }
        }