activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r1208377 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/transport/failover/FailoverTransport.java test/java/org/apache/activemq/transport/failover/FailoverTransportTest.java
Date Wed, 30 Nov 2011 10:58:22 GMT
Author: gtully
Date: Wed Nov 30 10:58:21 2011
New Revision: 1208377

URL: http://svn.apache.org/viewvc?rev=1208377&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-2730 - test to validate there is no implicit limit
on reconnects due to the task runner exceeding its iterations, if the task is not complete
it re queues it, so at least on trunk, the taskrunner issue is resolved

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverTransportTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java?rev=1208377&r1=1208376&r2=1208377&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
Wed Nov 30 10:58:21 2011
@@ -952,7 +952,8 @@ public class FailoverTransport implement
 
             int reconnectLimit = calculateReconnectAttemptLimit();
 
-            if (reconnectLimit != INFINITE && ++connectFailures >= reconnectLimit)
{
+            connectFailures++;
+            if (reconnectLimit != INFINITE && connectFailures >= reconnectLimit)
{
                 LOG.error("Failed to connect to " + uris + " after: " + connectFailures +
" attempt(s)");
                 connectionFailure = failure;
 
@@ -1158,6 +1159,10 @@ public class FailoverTransport implement
         return transport.getReceiveCounter();
     }
 
+    public int getConnectFailures() {
+        return connectFailures;
+    }
+
     public void connectionInterruptProcessingComplete(ConnectionId connectionId) {
         synchronized (reconnectMutex) {
             stateTracker.connectionInterruptProcessingComplete(this, connectionId);

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverTransportTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverTransportTest.java?rev=1208377&r1=1208376&r2=1208377&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverTransportTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverTransportTest.java
Wed Nov 30 10:58:21 2011
@@ -28,6 +28,7 @@ import org.apache.activemq.state.Connect
 import org.apache.activemq.transport.Transport;
 import org.apache.activemq.transport.TransportFactory;
 import org.apache.activemq.transport.TransportListener;
+import org.apache.activemq.util.Wait;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -41,6 +42,7 @@ public class FailoverTransportTest {
 
 	@Before
 	public void setUp() throws Exception {
+        commandsReceived = 0;
 	}
 
 	@After
@@ -50,7 +52,40 @@ public class FailoverTransportTest {
         }
     }
 
-	@Test(timeout=30000)
+    @Test(timeout = 30000)
+    public void testReconnectUnlimited() throws Exception {
+
+        Transport transport = TransportFactory.connect(
+                new URI("failover://(tcp://0.0.0.0:61616)?useExponentialBackOff=false&reconnectDelay=0&initialReconnectDelay=0"));
+
+        transport.setTransportListener(new TransportListener() {
+
+            public void onCommand(Object command) {
+                commandsReceived++;
+            }
+
+            public void onException(IOException error) {
+            }
+
+            public void transportInterupted() {
+            }
+
+            public void transportResumed() {
+            }
+        });
+        transport.start();
+
+        this.failoverTransport = transport.narrow(FailoverTransport.class);
+
+        assertTrue("no implicit limit of 1000", Wait.waitFor(new Wait.Condition() {
+            @Override
+            public boolean isSatisified() throws Exception {
+                return failoverTransport.getConnectFailures() > 1002;
+            }
+        }));
+    }
+
+    @Test(timeout=30000)
 	public void testCommandsIgnoredWhenOffline() throws Exception {
 		this.transport = createTransport();
 



Mime
View raw message