You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2016/05/06 12:54:38 UTC

activemq git commit: tackle ci intermittent failure - think with prefetch extension it is not guarenteed that second consumer will get a dispatch

Repository: activemq
Updated Branches:
  refs/heads/master fc9ad9f02 -> 1de7e7e8a


tackle ci intermittent failure - think with prefetch extension it is not guarenteed that second consumer will get a dispatch


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

Branch: refs/heads/master
Commit: 1de7e7e8a372e63d4fbae61ec8c111a179ff2413
Parents: fc9ad9f
Author: gtully <ga...@gmail.com>
Authored: Fri May 6 13:54:12 2016 +0100
Committer: gtully <ga...@gmail.com>
Committed: Fri May 6 13:54:12 2016 +0100

----------------------------------------------------------------------
 .../transport/failover/FailoverTransactionTest.java | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/1de7e7e8/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
index 3d29ee0..bb02ffe 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
@@ -29,6 +29,8 @@ import org.apache.activemq.broker.ConnectionContext;
 import org.apache.activemq.broker.ConsumerBrokerExchange;
 import org.apache.activemq.broker.ProducerBrokerExchange;
 import org.apache.activemq.broker.region.RegionBroker;
+import org.apache.activemq.broker.region.policy.PolicyEntry;
+import org.apache.activemq.broker.region.policy.PolicyMap;
 import org.apache.activemq.broker.util.DestinationPathSeparatorBroker;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ConsumerInfo;
@@ -57,6 +59,7 @@ import java.net.URI;
 import java.util.ArrayDeque;
 import java.util.Deque;
 import java.util.NoSuchElementException;
+import java.util.Random;
 import java.util.Stack;
 import java.util.Vector;
 import java.util.concurrent.CountDownLatch;
@@ -75,6 +78,7 @@ public class FailoverTransactionTest extends TestSupport {
     private static final String TRANSPORT_URI = "tcp://localhost:0";
     private String url;
     BrokerService broker;
+    final Random random = new Random();
 
     public static Test suite() {
         return suite(FailoverTransactionTest.class);
@@ -122,6 +126,12 @@ public class FailoverTransactionTest extends TestSupport {
         broker.addConnector(bindAddress);
         broker.setDeleteAllMessagesOnStartup(deleteAllMessagesOnStartup);
 
+        PolicyMap policyMap = new PolicyMap();
+        PolicyEntry defaultEntry = new PolicyEntry();
+        defaultEntry.setUsePrefetchExtension(false);
+        policyMap.setDefaultEntry(defaultEntry);
+        broker.setDestinationPolicy(policyMap);
+
         url = broker.getTransportConnectors().get(0).getConnectUri().toString();
 
         return broker;
@@ -763,12 +773,12 @@ public class FailoverTransactionTest extends TestSupport {
         connection = cf.createConnection();
         connection.start();
         connections.add(connection);
-        final Session consumerSession1 = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
+        final Session consumerSession1 = connection.createSession(true, Session.SESSION_TRANSACTED);
 
         connection = cf.createConnection();
         connection.start();
         connections.add(connection);
-        final Session consumerSession2 = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
+        final Session consumerSession2 = connection.createSession(true, Session.SESSION_TRANSACTED);
 
         final MessageConsumer consumer1 = consumerSession1.createConsumer(destination);
         final MessageConsumer consumer2 = consumerSession2.createConsumer(destination);
@@ -788,7 +798,7 @@ public class FailoverTransactionTest extends TestSupport {
                     receivedMessages.add(msg);
 
                     // give some variance to the runs
-                    TimeUnit.SECONDS.sleep(pauseSeconds * 2);
+                    TimeUnit.SECONDS.sleep(random.nextInt(5));
 
                     // should not get a second message as there are two messages and two consumers
                     // and prefetch=1, but with failover and unordered connection restore it can get the second