Uploaded image for project: 'Qpid'
  1. Qpid
  2. QPID-5931

[Java client] JMSException instead of InvalidDestinationException raised when sending to temporary destination after session closure

    XMLWordPrintableJSON

    Details

      Description

      An attempt to send to an auxiliary queue after the relevant session is closed should raise InvalidDestinationException. But javax.jms.JMSException is raised instead.

      junit test for this follows:

      ~~~
      package org.apache.qpid.example;

      import static org.junit.Assert.assertEquals;
      import static org.junit.Assert.assertNotNull;
      import static org.junit.Assert.fail;

      import org.apache.qpid.client.AMQConnection;
      import org.apache.qpid.client.AMQAnyDestination;

      import javax.jms.Connection;
      import javax.jms.ConnectionFactory;
      import javax.jms.Destination;
      import javax.jms.InvalidDestinationException;
      import javax.jms.JMSException;
      import javax.jms.MessageConsumer;
      import javax.jms.MessageProducer;
      import javax.jms.Session;
      import javax.jms.TemporaryQueue;
      import javax.jms.TextMessage;

      import org.junit.After;
      import org.junit.Before;
      import org.junit.Test;

      public class InvalidDestinationTest
      {
      private Destination destination;
      private ConnectionFactory conFac;
      private Connection publisherConnection;
      private Session publisherSession;
      private Connection consumerConnection;
      private Session consumerSession;
      private MessageProducer publisherMsgProducer;
      private MessageConsumer consumerMsgConsumer;
      private MessageProducer consumerMsgProducer;
      private TemporaryQueue replyToQueue;

      public void setupQpid() throws Exception
      {
      destination = new AMQAnyDestination("demoQueue;

      {create: always}

      ");

      String brokerlist = "amqp://guest:guest@guest/test?brokerlist='tcp://localhost:5672'";
      publisherConnection = new AMQConnection(brokerlist);
      publisherSession = publisherConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);

      consumerConnection = new AMQConnection(brokerlist);;
      consumerSession = consumerConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
      }

      @Before
      public void before() throws Exception

      { setupQpid(); }

      @After
      public void after() throws Exception

      { consumerSession.close(); consumerConnection.close(); publisherSession.close(); publisherConnection.close(); }

      @Test
      public void sendToTempQueueWhenItDoesNotExist() throws Exception
      {
      consumerMsgConsumer = consumerSession.createConsumer(destination);
      consumerConnection.start();
      publisherMsgProducer = publisherSession.createProducer(destination);
      replyToQueue = publisherSession.createTemporaryQueue();
      publisherConnection.close();

      TextMessage response = consumerSession.createTextMessage("");
      consumerMsgProducer = consumerSession.createProducer(replyToQueue);
      try

      { consumerMsgProducer.send(response); }

      catch (InvalidDestinationException e)

      { //expect to get this exception }

      catch (JMSException e)

      { e.printStackTrace(); fail("Unexpected exception type"); }

      }
      }
      ~~~

        Attachments

          Activity

            People

            • Assignee:
              pmoravec Pavel Moravec
              Reporter:
              pmoravec Pavel Moravec
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: