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(); + } + }