You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Matthew Good (JIRA)" <ji...@apache.org> on 2013/04/01 19:11:18 UTC

[jira] [Created] (AMQNET-424) Creating consumer with invalid selector closes connection and other listeners.

Matthew Good created AMQNET-424:
-----------------------------------

             Summary: Creating consumer with invalid selector closes connection and other listeners.
                 Key: AMQNET-424
                 URL: https://issues.apache.org/jira/browse/AMQNET-424
             Project: ActiveMQ .Net
          Issue Type: Bug
          Components: NMS
    Affects Versions: 1.5.5
         Environment: .NET 2.0
            Reporter: Matthew Good
            Assignee: Jim Gomes


The following test illustrates the problem.  After the exception trying to create a consumer, the connection is closed which affects other unrelated consumers and senders.  The connection should not close and other consumers should not be closed.



        [Test]
        public void TestBadSelector()
        {
            ConnectionFactory factory = new ConnectionFactory("tcp://activemqhost:61616");
            IConnection conn = factory.CreateConnection();
            ISession listenerSession = conn.CreateSession(AcknowledgementMode.AutoAcknowledge);

            string listenerQueueName = "ListenerTest";
            IDestination listenerdestination = listenerSession.GetQueue(listenerQueueName);
            IMessageConsumer listenerconsumer = listenerSession.CreateConsumer(listenerdestination);
            listenerconsumer.Listener += new MessageListener(consumer_Listener);

            conn.Start();

            ISession senderSession = conn.CreateSession(AcknowledgementMode.AutoAcknowledge);
            IDestination destination = senderSession.GetQueue(listenerQueueName);
            IMessageProducer producer = senderSession.CreateProducer(destination);
            ITextMessage goodMsg = senderSession.CreateTextMessage("testGood");
            producer.Send(goodMsg);


            Thread.Sleep(1000);
            Assert.AreEqual(1, _gotMessage);


            try
            {
                ISession badListenerSession = conn.CreateSession(AcknowledgementMode.AutoAcknowledge);
                IMessageConsumer consumer2 = badListenerSession.CreateConsumer(destination, "badSelector;too");
                Assert.Fail("Exception expected.");
            }
            catch(BrokerException   e)
            {
                Console.WriteLine(e);
            }

            ITextMessage failMsg = senderSession.CreateTextMessage("testFail");
            producer.Send(failMsg);


            Thread.Sleep(1000);
            Assert.AreEqual(2, _gotMessage);

            conn.Close();
        }

        private int _gotMessage = 0;
        void consumer_Listener(IMessage message)
        {
            _gotMessage++;
        }



--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira