Skip to content
Permalink
Browse files
AXIS2-4759: Applied patch submitted by Grant Patterson. Fixed JMSSend…
…er/JMSConnectionFactory so that JMS connections are properly closed when the JMS transport sender is stopped.
  • Loading branch information
veithen committed Jul 3, 2010
1 parent e4e23d1 commit 7906e71dc0313cf1d51db001c183bfdf2acdd2bf
Showing 3 changed files with 34 additions and 3 deletions.
@@ -125,6 +125,19 @@ private void digestCacheLevel() {
throw new AxisJMSException("Invalid cache level : " + val + " for JMS CF : " + name);
}
}

/**
* Close all connections, sessions etc.. and stop this connection factory
*/
public synchronized void stop() {
if (sharedConnection != null) {
try {
sharedConnection.close();
} catch (JMSException e) {
log.warn("Error shutting down connection factory : " + name, e);
}
}
}

/**
* Return the name assigned to this JMS CF definition
@@ -366,7 +379,7 @@ public MessageProducer getMessageProducer(
* Get a new Connection or shared Connection from this JMS CF
* @return new or shared Connection from this JMS CF
*/
private Connection getSharedConnection() {
private synchronized Connection getSharedConnection() {
if (sharedConnection == null) {
sharedConnection = createConnection();
if (log.isDebugEnabled()) {
@@ -380,7 +393,7 @@ private Connection getSharedConnection() {
* Get a shared Session from this JMS CF
* @return shared Session from this JMS CF
*/
private Session getSharedSession() {
private synchronized Session getSharedSession() {
if (sharedSession == null) {
sharedSession = createSession(getSharedConnection());
if (log.isDebugEnabled()) {
@@ -394,7 +407,7 @@ private Session getSharedSession() {
* Get a shared MessageProducer from this JMS CF
* @return shared MessageProducer from this JMS CF
*/
private MessageProducer getSharedProducer() {
private synchronized MessageProducer getSharedProducer() {
if (sharedProducer == null) {
sharedProducer = createProducer(getSharedSession(), sharedDestination);
if (log.isDebugEnabled()) {
@@ -113,6 +113,15 @@ public JMSConnectionFactory getJMSConnectionFactory(Map<String,String> props) {
private static boolean equals(Object s1, Object s2) {
return s1 == s2 || s1 != null && s1.equals(s2);
}

/**
* Stop all connection factories.
*/
public void stop() {
for (JMSConnectionFactory conFac : connectionFactories.values()) {
conFac.stop();
}
}

protected void handleException(String msg, Exception e) throws AxisFault {
log.error(msg, e);
@@ -64,6 +64,15 @@ public void init(ConfigurationContext cfgCtx, TransportOutDescription transportO
connFacManager = new JMSConnectionFactoryManager(transportOut);
log.info("JMS Transport Sender initialized...");
}

@Override
public void stop() {

// clean up any shared JMS resources in this sender's connection factories
connFacManager.stop();

super.stop();
}

/**
* Get corresponding JMS connection factory defined within the transport sender for the

0 comments on commit 7906e71

Please sign in to comment.