activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject git commit: https://issues.apache.org/jira/browse/AMQ-5231
Date Wed, 18 Jun 2014 16:59:09 GMT
Repository: activemq
Updated Branches:
  refs/heads/trunk d69498407 -> 8824ac9fc


https://issues.apache.org/jira/browse/AMQ-5231

Only apply timeout to the Message sends, other commands are handled
separately as needed.  

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

Branch: refs/heads/trunk
Commit: 8824ac9fcb245c0191471ac9190fbf9ef652589c
Parents: d694984
Author: Timothy Bish <tabish121@gmail.com>
Authored: Wed Jun 18 12:58:50 2014 -0400
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Wed Jun 18 12:58:50 2014 -0400

----------------------------------------------------------------------
 .../transport/failover/FailoverTransport.java   |  2 +-
 .../transport/failover/FailoverTimeoutTest.java | 47 +++++++++++++++++++-
 2 files changed, 46 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/8824ac9f/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
b/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
index 2829d41..6df82ed 100755
--- a/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
+++ b/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
@@ -602,7 +602,7 @@ public class FailoverTransport implements CompositeTransport {
                                 LOG.trace("Waiting for transport to reconnect..: " + command);
                             }
                             long end = System.currentTimeMillis();
-                            if (timeout > 0 && (end - start > timeout)) {
+                            if (command.isMessage() && timeout > 0 &&
(end - start > timeout)) {
                                 timedout = true;
                                 if (LOG.isInfoEnabled()) {
                                     LOG.info("Failover timed out after " + (end - start)
+ "ms");

http://git-wip-us.apache.org/repos/asf/activemq/blob/8824ac9f/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTimeoutTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTimeoutTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTimeoutTest.java
index e52b2c7..9ef6e28 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTimeoutTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTimeoutTest.java
@@ -16,23 +16,36 @@
  */
 package org.apache.activemq.transport.failover;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.net.URI;
+
 import javax.jms.Connection;
 import javax.jms.JMSException;
 import javax.jms.MessageProducer;
 import javax.jms.Session;
 import javax.jms.TextMessage;
-import junit.framework.TestCase;
+
 import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.broker.BrokerService;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FailoverTimeoutTest {
 
-public class FailoverTimeoutTest extends TestCase {
+    private static final Logger LOG = LoggerFactory.getLogger(FailoverTimeoutTest.class);
 
     private static final String QUEUE_NAME = "test.failovertimeout";
     BrokerService bs;
     URI tcpUri;
 
+    @Before
     public void setUp() throws Exception {
         bs = new BrokerService();
         bs.setUseJmx(false);
@@ -41,12 +54,41 @@ public class FailoverTimeoutTest extends TestCase {
         tcpUri = bs.getTransportConnectors().get(0).getConnectUri();
     }
 
+    @After
     public void tearDown() throws Exception {
         if (bs != null) {
             bs.stop();
         }
     }
 
+    @Test
+    public void testTimoutDoesNotFailConnectionAttempts() throws Exception {
+        bs.stop();
+        long timeout = 1000;
+
+        long startTime = System.currentTimeMillis();
+
+        ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(
+            "failover:(" + tcpUri + ")" +
+            "?timeout=" + timeout + "&useExponentialBackOff=false" +
+            "&maxReconnectAttempts=5" + "&initialReconnectDelay=1000");
+        Connection connection = cf.createConnection();
+        try {
+            connection.start();
+            fail("Should have failed to connect");
+        } catch (JMSException ex) {
+            LOG.info("Caught exception on call to start: {}", ex.getMessage());
+        }
+
+        long endTime = System.currentTimeMillis();
+        long duration = endTime - startTime;
+
+        LOG.info("Time spent waiting to connect: {} ms", duration);
+
+        assertTrue(duration > 3000);
+    }
+
+    @Test
     public void testTimeout() throws Exception {
 
         long timeout = 1000;
@@ -77,6 +119,7 @@ public class FailoverTimeoutTest extends TestCase {
         bs.stop();
     }
 
+    @Test
     public void testUpdateUris() throws Exception {
 
         ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + tcpUri
+ ")?useExponentialBackOff=false");


Mime
View raw message