activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-5983 - mqtt virtual topic queue restore
Date Mon, 28 Sep 2015 11:10:40 GMT
Repository: activemq
Updated Branches:
  refs/heads/master d6682e547 -> 4a8fec4a6


https://issues.apache.org/jira/browse/AMQ-5983 - mqtt virtual topic queue restore


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

Branch: refs/heads/master
Commit: 4a8fec4a6698552ee14c232f122f3c7387679b38
Parents: d6682e5
Author: Dejan Bosanac <dejan@nighttale.net>
Authored: Mon Sep 28 13:10:19 2015 +0200
Committer: Dejan Bosanac <dejan@nighttale.net>
Committed: Mon Sep 28 13:10:31 2015 +0200

----------------------------------------------------------------------
 .../MQTTVirtualTopicSubscriptionStrategy.java   |  4 +-
 .../activemq/transport/mqtt/PahoMQTTTest.java   | 48 ++++++++++++++++++++
 2 files changed, 50 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/4a8fec4a/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/strategy/MQTTVirtualTopicSubscriptionStrategy.java
----------------------------------------------------------------------
diff --git a/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/strategy/MQTTVirtualTopicSubscriptionStrategy.java
b/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/strategy/MQTTVirtualTopicSubscriptionStrategy.java
index 468e823..457981a 100644
--- a/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/strategy/MQTTVirtualTopicSubscriptionStrategy.java
+++ b/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/strategy/MQTTVirtualTopicSubscriptionStrategy.java
@@ -226,7 +226,7 @@ public class MQTTVirtualTopicSubscriptionStrategy extends AbstractMQTTSubscripti
                 });
             }
         } catch (Throwable e) {
-            LOG.warn("Could not delete the MQTT queue subsscriptions.", e);
+            LOG.warn("Could not delete the MQTT queue subscriptions.", e);
         }
     }
 
@@ -274,7 +274,7 @@ public class MQTTVirtualTopicSubscriptionStrategy extends AbstractMQTTSubscripti
         final QueueRegion queueRegion = (QueueRegion) regionBroker.getQueueRegion();
         for (ActiveMQDestination destination : queueRegion.getDestinationMap().keySet())
{
             if (destination.isQueue() && !destination.isTemporary()) {
-                if (destination.getPhysicalName().startsWith("Consumer." + clientId)) {
+                if (destination.getPhysicalName().startsWith("Consumer." + clientId + ":"))
{
                     LOG.debug("Recovered client sub: {} on connect", destination.getPhysicalName());
                     result.add((ActiveMQQueue) destination);
                 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/4a8fec4a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/PahoMQTTTest.java
----------------------------------------------------------------------
diff --git a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/PahoMQTTTest.java
b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/PahoMQTTTest.java
index fac843b..3e149ec 100644
--- a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/PahoMQTTTest.java
+++ b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/PahoMQTTTest.java
@@ -18,6 +18,9 @@ package org.apache.activemq.transport.mqtt;
 
 
 import org.apache.activemq.ActiveMQConnection;
+import org.apache.activemq.broker.region.Destination;
+import org.apache.activemq.broker.region.RegionBroker;
+import org.apache.activemq.command.ActiveMQQueue;
 import org.apache.activemq.util.Wait;
 import org.eclipse.paho.client.mqttv3.*;
 import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
@@ -350,6 +353,51 @@ public class PahoMQTTTest extends MQTTTestSupport {
         assertEquals(0, listener.received);
     }
 
+    @Test(timeout = 300000)
+    public void testVirtualTopicQueueRestore() throws Exception {
+
+        stopBroker();
+        protocolConfig = "transport.subscriptionStrategy=mqtt-virtual-topic-subscriptions";
+        startBroker();
+
+        String user10 = "user10";
+        String password10 = "user10";
+        String clientId10 = "client-10";
+        String topic10 = "user10/";
+        MqttConnectOptions options10 = new MqttConnectOptions();
+        options10.setCleanSession(false);
+        options10.setUserName(user10);
+        options10.setPassword(password10.toCharArray());
+        MqttClient client10 = createClient(false, clientId10, null);
+        client10.subscribe(topic10 + clientId10 + "/#", 1);
+        client10.subscribe(topic10 + "#", 1);
+
+        String user1 = "user1";
+        String password1 = "user1";
+        String clientId1 = "client-1";
+        String topic1 = "user1/";
+        MqttConnectOptions options1 = new MqttConnectOptions();
+        options1.setCleanSession(false);
+        options1.setUserName(user1);
+        options1.setPassword(password1.toCharArray());
+
+        MqttClient client1 = createClient(false, clientId1, null);
+        client1.subscribe(topic1 + clientId1 + "/#", 1);
+        client1.subscribe(topic1 + "#", 1);
+
+        RegionBroker regionBroker = (RegionBroker) brokerService.getBroker().getAdaptor(RegionBroker.class);
+
+        String[] queues = new String[]{"Consumer.client-10:AT_LEAST_ONCE.VirtualTopic.user10.>",
+                "Consumer.client-10:AT_LEAST_ONCE.VirtualTopic.user10.client-10.>",
+                "Consumer.client-1:AT_LEAST_ONCE.VirtualTopic.user1.>",
+                "Consumer.client-1:AT_LEAST_ONCE.VirtualTopic.user1.client-1.>"};
+
+        for (String queueName : queues) {
+            Destination queue = regionBroker.getQueueRegion().getDestinations(new ActiveMQQueue(queueName)).iterator().next();
+            assertEquals("Queue " + queueName + " have more than one consumer", 1, queue.getConsumers().size());
+        }
+    }
+
     protected MqttClient createClient(boolean cleanSession, String clientId, MqttCallback
listener) throws Exception {
         MqttConnectOptions options = new MqttConnectOptions();
         options.setCleanSession(cleanSession);


Mime
View raw message