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

PopulateDestinationWithInterleavedProducer() private method

private PopulateDestinationWithInterleavedProducer ( int nbMessages, string destinationName ) : void
nbMessages int
destinationName string
return void
        private void PopulateDestinationWithInterleavedProducer(int nbMessages, string destinationName)
        {
            ISession session1 = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
            IDestination destination1 = session1.GetQueue(destinationName);
            IMessageProducer producer1 = session1.CreateProducer(destination1);
            producer1.DeliveryMode = MsgDeliveryMode.NonPersistent;

            ISession session2 = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
            IDestination destination2 = session2.GetQueue(destinationName);
            IMessageProducer producer2 = session2.CreateProducer(destination2);
            producer2.DeliveryMode = MsgDeliveryMode.NonPersistent;

            for(int i = 1; i <= nbMessages; i++)
            {
                if(i%2 == 0)
                {
                    producer1.Send(session1.CreateTextMessage("<hello id='" + i + "'/>"));
                }
                else
                {
                    producer2.Send(session2.CreateTextMessage("<hello id='" + i + "'/>"));
                }
            }

            producer1.Close();
            session1.Close();
            producer2.Close();
            session2.Close();
        }