activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-5598
Date Fri, 06 Mar 2015 21:27:08 GMT
Repository: activemq
Updated Branches:
  refs/heads/master dd35e357e -> 1c72579d7


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

Parallel connection test, could not reproduce issue.

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

Branch: refs/heads/master
Commit: 1c72579d7a0017bd22e800e47d34e3f748601a9a
Parents: dd35e35
Author: Timothy Bish <tabish121@gmail.com>
Authored: Fri Mar 6 16:26:53 2015 -0500
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Fri Mar 6 16:27:04 2015 -0500

----------------------------------------------------------------------
 .../transport/mqtt/MQTTConnectTest.java         | 36 ++++++++++++++++++++
 1 file changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/1c72579d/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTConnectTest.java
----------------------------------------------------------------------
diff --git a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTConnectTest.java
b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTConnectTest.java
index c924bf9..e14c135 100644
--- a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTConnectTest.java
+++ b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTConnectTest.java
@@ -22,11 +22,16 @@ import java.io.IOException;
 import java.net.Socket;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import javax.net.ssl.SSLSocketFactory;
 
 import org.apache.activemq.util.Wait;
+import org.fusesource.mqtt.client.BlockingConnection;
+import org.fusesource.mqtt.client.MQTT;
 import org.junit.After;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -77,6 +82,37 @@ public class MQTTConnectTest extends MQTTTestSupport {
         return "transport.connectAttemptTimeout=1000";
     }
 
+    @Test(timeout = 90000)
+    public void testParallelConnectPlain() throws Exception {
+        final int THREAD_COUNT = 16;
+        final int CONNECTION_COUNT = 100;
+        ExecutorService executorService = Executors.newFixedThreadPool(THREAD_COUNT);
+        final AtomicInteger clientIdGemeratpr = new AtomicInteger();
+        for (int i = 0; i < CONNECTION_COUNT; i++) {
+            executorService.execute(new Runnable() {
+                @Override
+                public void run() {
+
+                    try {
+                        MQTT mqtt = createMQTTConnection();
+                        mqtt.setClientId("client-" + clientIdGemeratpr.incrementAndGet());
+                        mqtt.setCleanSession(true);
+
+                        BlockingConnection connection = mqtt.blockingConnection();
+                        connection.connect();
+                        connection.disconnect();
+                    } catch (Exception e) {
+                        LOG.error("unexpected exception on connect/disconnect", e);
+                        exceptions.add(e);
+                    }
+                }
+            });
+        }
+
+        executorService.shutdown();
+        assertTrue("executor done on time", executorService.awaitTermination(60, TimeUnit.SECONDS));
+    }
+
     @Test(timeout = 60 * 1000)
     public void testInactivityMonitor() throws Exception {
 


Mime
View raw message