From cc1de0e202b3b6fb5dc3522d3909fb687d4f5abe Mon Sep 17 00:00:00 2001 From: James Strachan Date: Thu, 5 Jan 2006 11:14:38 +0000 Subject: [PATCH] fix for AMQ-348 to allow a ConnectionFactory to be specified so it can be shared across inbound and outputbound messaging git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@366161 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/ra/ActiveMQResourceAdapter.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java index 231fa8260d..d614e51a99 100755 --- a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java +++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java @@ -57,6 +57,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter { private BootstrapContext bootstrapContext; private String brokerXmlConfig; private BrokerService broker; + private ActiveMQConnectionFactory connectionFactory; public ActiveMQResourceAdapter() { } @@ -77,7 +78,12 @@ public class ActiveMQResourceAdapter implements ResourceAdapter { } public ActiveMQConnection makeConnection() throws JMSException { - return makeConnection(info); + if (connectionFactory != null) { + return makeConnection(info, connectionFactory); + } + else { + return makeConnection(info); + } } /** @@ -85,6 +91,10 @@ public class ActiveMQResourceAdapter implements ResourceAdapter { public ActiveMQConnection makeConnection(ActiveMQConnectionRequestInfo info) throws JMSException { ActiveMQConnectionFactory connectionFactory = createConnectionFactory(info); + return makeConnection(info, connectionFactory); + } + + public ActiveMQConnection makeConnection(ActiveMQConnectionRequestInfo info, ActiveMQConnectionFactory connectionFactory) throws JMSException { String userName = info.getUserName(); String password = info.getPassword(); ActiveMQConnection physicalConnection = (ActiveMQConnection) connectionFactory.createConnection(userName, password); @@ -459,5 +469,18 @@ public class ActiveMQResourceAdapter implements ResourceAdapter { info.setUseInboundSession(useInboundSession); } + public ActiveMQConnectionFactory getConnectionFactory() { + return connectionFactory; + } + + /** + * This allows a connection factory to be configured and shared between a ResourceAdaptor and outbound messaging. + * Note that setting the connectionFactory will overload many of the properties on this POJO such as the redelivery + * and prefetch policies; the properties on the connectionFactory will be used instead. + */ + public void setConnectionFactory(ActiveMQConnectionFactory connectionFactory) { + this.connectionFactory = connectionFactory; + } + }