activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-5794 - duplex network case calls start twice and would start a connect check timer in error. Fix is to only start connectiontimeout if we have not already started the rest of the monitoring
Date Wed, 12 Aug 2015 15:19:31 GMT
Repository: activemq
Updated Branches:
  refs/heads/master 04ee70a16 -> e5a94bfee


https://issues.apache.org/jira/browse/AMQ-5794 - duplex network case calls start twice and
would start a connect check timer in error. Fix is to only start connectiontimeout if we have
not already started the rest of the monitoring


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/e5a94bfe
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/e5a94bfe
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/e5a94bfe

Branch: refs/heads/master
Commit: e5a94bfee2bc850f1999c58c2916655e8caba2d3
Parents: 04ee70a
Author: gtully <gary.tully@gmail.com>
Authored: Wed Aug 12 16:07:05 2015 +0100
Committer: gtully <gary.tully@gmail.com>
Committed: Wed Aug 12 16:07:34 2015 +0100

----------------------------------------------------------------------
 .../transport/AbstractInactivityMonitor.java    |  2 +-
 .../activemq/transport/InactivityMonitor.java   |  4 ++-
 .../activemq/network/DuplexNetworkTest.java     | 31 +++++++++++++++++++-
 3 files changed, 34 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/e5a94bfe/activemq-client/src/main/java/org/apache/activemq/transport/AbstractInactivityMonitor.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/transport/AbstractInactivityMonitor.java
b/activemq-client/src/main/java/org/apache/activemq/transport/AbstractInactivityMonitor.java
index 256c9d7..7bd19c4 100644
--- a/activemq-client/src/main/java/org/apache/activemq/transport/AbstractInactivityMonitor.java
+++ b/activemq-client/src/main/java/org/apache/activemq/transport/AbstractInactivityMonitor.java
@@ -89,7 +89,7 @@ public abstract class AbstractInactivityMonitor extends TransportFilter
{
                         @Override
                         public void run() {
                             onException(new InactivityIOException(
-                                "Channel was inactive for too (>" + (connectAttemptTimeout)
+ ") long: " + next.getRemoteAddress()));
+                                "Channel was inactive (no connection attempt made) for too
(>" + (connectAttemptTimeout) + ") long: " + next.getRemoteAddress()));
                         }
                     });
                 } catch (RejectedExecutionException ex) {

http://git-wip-us.apache.org/repos/asf/activemq/blob/e5a94bfe/activemq-client/src/main/java/org/apache/activemq/transport/InactivityMonitor.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/transport/InactivityMonitor.java
b/activemq-client/src/main/java/org/apache/activemq/transport/InactivityMonitor.java
index 288ec61..d86699b 100755
--- a/activemq-client/src/main/java/org/apache/activemq/transport/InactivityMonitor.java
+++ b/activemq-client/src/main/java/org/apache/activemq/transport/InactivityMonitor.java
@@ -46,7 +46,9 @@ public class InactivityMonitor extends AbstractInactivityMonitor {
 
     @Override
     public void start() throws Exception {
-        startConnectCheckTask();
+        if (!isMonitorStarted()) {
+            startConnectCheckTask();
+        }
         super.start();
     }
 

http://git-wip-us.apache.org/repos/asf/activemq/blob/e5a94bfe/activemq-unit-tests/src/test/java/org/apache/activemq/network/DuplexNetworkTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/network/DuplexNetworkTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/network/DuplexNetworkTest.java
index 3afa7d1..14b2e0f 100755
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/network/DuplexNetworkTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/network/DuplexNetworkTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.activemq.network;
 
+import java.util.concurrent.TimeUnit;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -25,8 +27,11 @@ import javax.jms.TemporaryQueue;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.util.Wait;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class DuplexNetworkTest extends SimpleNetworkTest {
+    private static final Logger LOG = LoggerFactory.getLogger(DuplexNetworkTest.class);
 
     @Override
     protected String getLocalBrokerURI() {
@@ -37,7 +42,7 @@ public class DuplexNetworkTest extends SimpleNetworkTest {
     protected BrokerService createRemoteBroker() throws Exception {
         BrokerService broker = new BrokerService();
         broker.setBrokerName("remoteBroker");
-        broker.addConnector("tcp://localhost:61617");
+        broker.addConnector("tcp://localhost:61617?transport.connectAttemptTimeout=2000");
         return broker;
     }
 
@@ -57,4 +62,28 @@ public class DuplexNetworkTest extends SimpleNetworkTest {
             }
         }));
     }
+
+    @Test
+    public void testStaysUp() throws Exception {
+        int bridgeIdentity = getBridgeId();
+        LOG.info("Bridges: " + bridgeIdentity);
+        TimeUnit.SECONDS.sleep(5);
+        assertEquals("Same bridges", bridgeIdentity, getBridgeId());
+    }
+
+    private int getBridgeId() {
+        int id = 0;
+        while (id == 0) {
+            try {
+                id = localBroker.getNetworkConnectors().get(0).activeBridges().iterator().next().hashCode();
+            } catch (Throwable tryAgainInABit) {
+                try {
+                    TimeUnit.MILLISECONDS.sleep(500);
+                } catch (InterruptedException ignored) {
+                }
+            }
+        }
+        return id;
+    }
+
 }


Mime
View raw message