Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 88189 invoked from network); 21 Feb 2010 07:37:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 21 Feb 2010 07:37:16 -0000 Received: (qmail 73227 invoked by uid 500); 21 Feb 2010 07:37:16 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 73182 invoked by uid 500); 21 Feb 2010 07:37:16 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 73173 invoked by uid 99); 21 Feb 2010 07:37:16 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 21 Feb 2010 07:37:16 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 21 Feb 2010 07:37:15 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 875D823888CF; Sun, 21 Feb 2010 07:36:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@activemq.apache.org From: rajdavies@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100221073655.875D823888CF@eris.apache.org> 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) {