You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Timothy Bish (JIRA)" <ji...@apache.org> on 2014/07/31 00:41:38 UTC

[jira] [Comment Edited] (AMQ-5298) MQTT Transport can generate class cast exception when subscription is to a Virtual Topic

    [ https://issues.apache.org/jira/browse/AMQ-5298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14080102#comment-14080102 ] 

Timothy Bish edited comment on AMQ-5298 at 7/30/14 10:40 PM:
-------------------------------------------------------------

This patch fixes the crash but there are issues with the retained messages because it's a VurtualTopic.

{noformat}
diff --git a/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/MQTTProtocolConverter.java b/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/MQTTProtocolConverter.java
index cc51ce7..af5f003 100644
--- a/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/MQTTProtocolConverter.java
+++ b/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/MQTTProtocolConverter.java
@@ -40,6 +40,7 @@
 import org.apache.activemq.broker.region.Subscription;
 import org.apache.activemq.broker.region.TopicRegion;
 import org.apache.activemq.broker.region.policy.RetainedMessageSubscriptionRecoveryPolicy;
+import org.apache.activemq.broker.region.virtual.VirtualTopicInterceptor;
 import org.apache.activemq.command.ActiveMQBytesMessage;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ActiveMQMapMessage;
@@ -503,7 +504,11 @@
             for (Subscription subscription : dest.getConsumers()) {
                 if (subscription.getConsumerInfo().getConsumerId().equals(consumerId)) {
                     try {
-                        ((org.apache.activemq.broker.region.Topic)dest).recoverRetroactiveMessages(connectionContext, subscription);
+                        if (dest instanceof org.apache.activemq.broker.region.Topic) {
+                            ((org.apache.activemq.broker.region.Topic)dest).recoverRetroactiveMessages(connectionContext, subscription);
+                        } else if (dest instanceof VirtualTopicInterceptor) {
+                            ((VirtualTopicInterceptor)dest).getTopic().recoverRetroactiveMessages(connectionContext, subscription);
+                        }
                         if (subscription instanceof PrefetchSubscription) {
                             // request dispatch for prefetch subs
                             PrefetchSubscription prefetchSubscription = (PrefetchSubscription) subscription;
{noformat}


was (Author: tabish121):
This patch fixes the crash but there are issues with the retained messages because it's a VurtualTopic.

{code}
diff --git a/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/MQTTProtocolConverter.java b/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/MQTTProtocolConverter.java
index cc51ce7..af5f003 100644
--- a/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/MQTTProtocolConverter.java
+++ b/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/MQTTProtocolConverter.java
@@ -40,6 +40,7 @@
 import org.apache.activemq.broker.region.Subscription;
 import org.apache.activemq.broker.region.TopicRegion;
 import org.apache.activemq.broker.region.policy.RetainedMessageSubscriptionRecoveryPolicy;
+import org.apache.activemq.broker.region.virtual.VirtualTopicInterceptor;
 import org.apache.activemq.command.ActiveMQBytesMessage;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ActiveMQMapMessage;
@@ -503,7 +504,11 @@
             for (Subscription subscription : dest.getConsumers()) {
                 if (subscription.getConsumerInfo().getConsumerId().equals(consumerId)) {
                     try {
-                        ((org.apache.activemq.broker.region.Topic)dest).recoverRetroactiveMessages(connectionContext, subscription);
+                        if (dest instanceof org.apache.activemq.broker.region.Topic) {
+                            ((org.apache.activemq.broker.region.Topic)dest).recoverRetroactiveMessages(connectionContext, subscription);
+                        } else if (dest instanceof VirtualTopicInterceptor) {
+                            ((VirtualTopicInterceptor)dest).getTopic().recoverRetroactiveMessages(connectionContext, subscription);
+                        }
                         if (subscription instanceof PrefetchSubscription) {
                             // request dispatch for prefetch subs
                             PrefetchSubscription prefetchSubscription = (PrefetchSubscription) subscription;
{code}

> MQTT Transport can generate class cast exception when subscription is to a Virtual Topic
> ----------------------------------------------------------------------------------------
>
>                 Key: AMQ-5298
>                 URL: https://issues.apache.org/jira/browse/AMQ-5298
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: MQTT
>    Affects Versions: 5.10.0
>            Reporter: Timothy Bish
>             Fix For: 5.11.0
>
>
> When a client subscribes to a Virtual Topic and sends a duplicate subscription request the method that resends the old retained messages tries to cast the destination from the TopicRegion is finds to a Topic but in this case it would be a VirtualTopicIntercepter and an exception is thrown disconnecting the client.



--
This message was sent by Atlassian JIRA
(v6.2#6252)