You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by "Pavel Moravec (JIRA)" <ji...@apache.org> on 2014/07/28 14:42:38 UTC

[jira] [Created] (QPID-5931) [Java client] JMSException instead of InvalidDestinationException raised when sending to temporary destination after session closure

Pavel Moravec created QPID-5931:
-----------------------------------

             Summary: [Java client]  JMSException instead of InvalidDestinationException raised when sending to temporary destination after session closure
                 Key: QPID-5931
                 URL: https://issues.apache.org/jira/browse/QPID-5931
             Project: Qpid
          Issue Type: Bug
          Components: Java Client
    Affects Versions: 0.28
            Reporter: Pavel Moravec
            Assignee: Pavel Moravec
            Priority: Trivial


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");
		}
	}	
}
~~~



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org