From 059fd2f8c427f9035d94ec87c2e539b2aab7670c Mon Sep 17 00:00:00 2001 From: Gary Tully Date: Tue, 2 Apr 2013 23:19:16 +0000 Subject: [PATCH] https://issues.apache.org/jira/browse/AMQ-4426 - queuesender and topicpublisher need to delegate destination tracking, otherwise anonymous publishers return null destination git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1463789 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/pool/PooledQueueSender.java | 2 +- .../apache/activemq/pool/PooledSession.java | 2 +- .../activemq/pool/PooledTopicPublisher.java | 2 +- .../activemq/pool/XAConnectionPoolTest.java | 23 +++++++++++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/activemq-pool/src/main/java/org/apache/activemq/pool/PooledQueueSender.java b/activemq-pool/src/main/java/org/apache/activemq/pool/PooledQueueSender.java index 4cf315f0dd..6624a3aa2b 100644 --- a/activemq-pool/src/main/java/org/apache/activemq/pool/PooledQueueSender.java +++ b/activemq-pool/src/main/java/org/apache/activemq/pool/PooledQueueSender.java @@ -45,7 +45,7 @@ public class PooledQueueSender extends PooledProducer implements QueueSender { @Override public Queue getQueue() throws JMSException { - return getQueueSender().getQueue(); + return (Queue) getDestination(); } protected ActiveMQQueueSender getQueueSender() { diff --git a/activemq-pool/src/main/java/org/apache/activemq/pool/PooledSession.java b/activemq-pool/src/main/java/org/apache/activemq/pool/PooledSession.java index 2456965ef8..6e206f68e0 100644 --- a/activemq-pool/src/main/java/org/apache/activemq/pool/PooledSession.java +++ b/activemq-pool/src/main/java/org/apache/activemq/pool/PooledSession.java @@ -149,7 +149,7 @@ public class PooledSession implements Session, TopicSession, QueueSession, XASes try { sessionPool.invalidateObject(key, this); } catch (Exception e) { - throw JMSExceptionSupport.create(e); + LOG.trace("Ignoring exception on invalidateObject as discarding session: " + e, e); } } else { try { diff --git a/activemq-pool/src/main/java/org/apache/activemq/pool/PooledTopicPublisher.java b/activemq-pool/src/main/java/org/apache/activemq/pool/PooledTopicPublisher.java index ea74297674..7b2af144cb 100644 --- a/activemq-pool/src/main/java/org/apache/activemq/pool/PooledTopicPublisher.java +++ b/activemq-pool/src/main/java/org/apache/activemq/pool/PooledTopicPublisher.java @@ -35,7 +35,7 @@ public class PooledTopicPublisher extends PooledProducer implements TopicPublish @Override public Topic getTopic() throws JMSException { - return getTopicPublisher().getTopic(); + return (Topic) getDestination(); } @Override diff --git a/activemq-pool/src/test/java/org/apache/activemq/pool/XAConnectionPoolTest.java b/activemq-pool/src/test/java/org/apache/activemq/pool/XAConnectionPoolTest.java index 898e7bf8a0..d13354be8e 100644 --- a/activemq-pool/src/test/java/org/apache/activemq/pool/XAConnectionPoolTest.java +++ b/activemq-pool/src/test/java/org/apache/activemq/pool/XAConnectionPoolTest.java @@ -18,7 +18,11 @@ package org.apache.activemq.pool; import java.util.Hashtable; import java.util.Vector; +import javax.jms.BytesMessage; +import javax.jms.QueueConnection; import javax.jms.QueueConnectionFactory; +import javax.jms.QueueSender; +import javax.jms.QueueSession; import javax.jms.Session; import javax.jms.TopicConnection; import javax.jms.TopicConnectionFactory; @@ -167,4 +171,23 @@ public class XAConnectionPoolTest extends TestSupport { assertFalse(pcf.isTmFromJndi()); } + public void testSenderAndPublisherDest() throws Exception { + XaPooledConnectionFactory pcf = new XaPooledConnectionFactory(); + pcf.setConnectionFactory(new ActiveMQXAConnectionFactory("vm://test?broker.persistent=false")); + + QueueConnection connection = pcf.createQueueConnection(); + QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); + QueueSender sender = session.createSender(session.createQueue("AA")); + assertNotNull(sender.getQueue().getQueueName()); + + connection.close(); + + TopicConnection topicConnection = pcf.createTopicConnection(); + TopicSession topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); + TopicPublisher topicPublisher = topicSession.createPublisher(topicSession.createTopic("AA")); + assertNotNull(topicPublisher.getTopic().getTopicName()); + + topicConnection.close(); + } + }