Apache.NMS.Test.TempDestinationTests.TempDestinationDeletionTest C# (CSharp) Method

TempDestinationDeletionTest() private method

private TempDestinationDeletionTest ( [ deliveryMode, [ destinationName ) : void
deliveryMode [
destinationName [
return void
        public void TempDestinationDeletionTest(
			[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
			MsgDeliveryMode deliveryMode,
			[Values(QUEUE_DESTINATION_NAME, TOPIC_DESTINATION_NAME, TEMP_QUEUE_DESTINATION_NAME, TEMP_TOPIC_DESTINATION_NAME)]
			string destinationName)
        {
            using(IConnection connection1 = CreateConnection(GetTestClientId()))
            {
                connection1.Start();
                using(ISession session = connection1.CreateSession(AcknowledgementMode.AutoAcknowledge))
                {
                    const int MaxNumDestinations = 100;

                    for(int index = 1; index <= MaxNumDestinations; index++)
                    {
                        IDestination destination = SessionUtil.GetDestination(session, destinationName);

                        using(IMessageProducer producer = session.CreateProducer(destination))
                        using(IMessageConsumer consumer = session.CreateConsumer(destination))
                        {
                            producer.DeliveryMode = deliveryMode;

                            IMessage request = session.CreateTextMessage("Hello World, Just Passing Through!");

                            request.NMSType = "TEMP_MSG";
                            producer.Send(request);
                            IMessage receivedMsg = consumer.Receive(TimeSpan.FromMilliseconds(5000));
                            Assert.IsNotNull(receivedMsg);
                            Assert.AreEqual(receivedMsg.NMSType, "TEMP_MSG");

                            // Ensures that Consumer closes out its subscription
                            consumer.Close();
                        }

                        try
                        {
                            session.DeleteDestination(destination);
                        }
                        catch(NotSupportedException)
                        {
                            // Might as well not try this again.
                            break;
                        }
                    }
                }
            }
        }
TempDestinationTests