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

TestRedeliveryPropertyWithNoRollback() private method

private TestRedeliveryPropertyWithNoRollback ( ) : void
return void
        public void TestRedeliveryPropertyWithNoRollback()
        {
            const int numMessages = 1;

            PopulateDestination(numMessages, destinationName);
            connection.Close();

            {
                int received = 0;

                int maxRetries = new RedeliveryPolicy().MaximumRedeliveries;

                while(received < maxRetries)
                {
                    connection = CreateConnection();
                    connection.Start();
                    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.Close();
                    connection.Close();
                }

                connection = CreateConnection();
                connection.Start();
                ConsumeMessage(maxRetries + 1);
            }
        }