activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r912312 - in /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms: DestinationBridge.java JmsQueueConnector.java
Date Sun, 21 Feb 2010 07:36:55 GMT
Author: rajdavies
Date: Sun Feb 21 07:36:55 2010
New Revision: 912312

URL: http://svn.apache.org/viewvc?rev=912312&view=rev
Log:
Applied patch for https://issues.apache.org/activemq/browse/AMQ-2455

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/DestinationBridge.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/JmsQueueConnector.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/DestinationBridge.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/DestinationBridge.java?rev=912312&r1=912311&r2=912312&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/DestinationBridge.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/DestinationBridge.java
Sun Feb 21 07:36:55 2010
@@ -17,7 +17,6 @@
 package org.apache.activemq.network.jms;
 
 import java.util.concurrent.atomic.AtomicBoolean;
-
 import javax.jms.Connection;
 import javax.jms.Destination;
 import javax.jms.JMSException;
@@ -26,7 +25,6 @@
 import javax.jms.MessageListener;
 import javax.jms.MessageProducer;
 import javax.naming.NamingException;
-
 import org.apache.activemq.Service;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -109,8 +107,9 @@
     }
 
     public void onMessage(Message message) {
-        if (started.get() && message != null) {
-            int attempt = 0;
+        int attempt = 0;
+        while (started.get() && message != null) {
+           
             try {
                 if (attempt > 0) {
                     restartProducer();
@@ -129,6 +128,7 @@
                 }
                 sendMessage(converted);
                 message.acknowledge();
+                return;
             } catch (Exception e) {
                 LOG.error("failed to forward message on attempt: " + (++attempt) + " reason:
" + e + " message: " + message, e);
                 if (maximumRetries > 0 && attempt >= maximumRetries) {
@@ -168,6 +168,8 @@
 
     protected void restartProducer() throws JMSException, NamingException {
         try {
+            //don't reconnect immediately
+            Thread.sleep(1000);
             getConnectionForProducer().close();
         } catch (Exception e) {
             LOG.debug("Ignoring failure to close producer connection: " + e, e);

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/JmsQueueConnector.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/JmsQueueConnector.java?rev=912312&r1=912311&r2=912312&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/JmsQueueConnector.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/JmsQueueConnector.java
Sun Feb 21 07:36:55 2010
@@ -182,6 +182,20 @@
     public void restartProducerConnection() throws NamingException, JMSException {
         outboundQueueConnection = null;
         initializeForeignQueueConnection();
+
+        // the outboundQueueConnection was reestablished - publish the new connection to
the bridges
+        if (inboundQueueBridges != null) {
+        	for (int i = 0; i < inboundQueueBridges.length; i++) {
+        		InboundQueueBridge bridge = inboundQueueBridges[i];
+        		bridge.setConsumerConnection(outboundQueueConnection);
+        	}
+        }
+        if (outboundQueueBridges != null) {
+        	for (int i = 0; i < outboundQueueBridges.length; i++) {
+        		OutboundQueueBridge bridge = outboundQueueBridges[i];
+        		bridge.setProducerConnection(outboundQueueConnection);
+        	}
+        }
     }
 
     protected void initializeForeignQueueConnection() throws NamingException, JMSException
{
@@ -199,7 +213,7 @@
                         outboundQueueConnection = outboundQueueConnectionFactory.createQueueConnection();
                     }
                 } else {
-                    throw new JMSException("Cannot create localConnection - no information");
+                    throw new JMSException("Cannot create foreignConnection - no information");
                 }
             } else {
                 if (outboundUsername != null) {



Mime
View raw message