Apache.NMS.ActiveMQ.Test.IndividualAckTest.TestManyMessageAckedAfterMessageConsumption C# (CSharp) Method

TestManyMessageAckedAfterMessageConsumption() private method

private TestManyMessageAckedAfterMessageConsumption ( ) : void
return void
        public void TestManyMessageAckedAfterMessageConsumption()
        {
            int messageCount = 20;
            IMessage msg;

            ISession session = connection.CreateSession(AcknowledgementMode.IndividualAcknowledge);
            ITemporaryQueue queue = session.CreateTemporaryQueue();
            IMessageProducer producer = session.CreateProducer(queue);
            for(int i = 0; i < messageCount; i++)
            {
                msg = session.CreateTextMessage("msg" + i);
                producer.Send(msg);
            }

            // Consume the message...
            IMessageConsumer consumer = session.CreateConsumer(queue);
            for(int i = 0; i < messageCount; i++)
            {
                msg = consumer.Receive(TimeSpan.FromMilliseconds(1000));
                Assert.IsNotNull(msg);
                msg.Acknowledge();
            }
            msg = consumer.Receive(TimeSpan.FromMilliseconds(1000));
            Assert.IsNull(msg);

            // Reset the session.
            session.Close();
            session = connection.CreateSession(AcknowledgementMode.IndividualAcknowledge);

            // Attempt to Consume the message...
            consumer = session.CreateConsumer(queue);
            msg = consumer.Receive(TimeSpan.FromMilliseconds(1000));
            Assert.IsNull(msg);
            session.Close();
        }