activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject git commit: More improvements for AMQ-5043. Drop all messages sent to topics starting '$' to honor MQTT 3.1.1 spec requirments.
Date Wed, 12 Feb 2014 18:53:13 GMT
Updated Branches:
  refs/heads/trunk 6e68a3711 -> 706830268


More improvements for AMQ-5043.  Drop all messages sent to topics starting '$' to honor MQTT
3.1.1 spec requirments.

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

Branch: refs/heads/trunk
Commit: 706830268e1cecfe165feb444ee5b62e954e7d33
Parents: 6e68a37
Author: Hiram Chirino <hiram@hiramchirino.com>
Authored: Wed Feb 12 13:53:18 2014 -0500
Committer: Hiram Chirino <hiram@hiramchirino.com>
Committed: Wed Feb 12 13:53:18 2014 -0500

----------------------------------------------------------------------
 .../transport/mqtt/MQTTProtocolConverter.java      | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/70683026/activemq-mqtt/src/main/java/org/apache/activemq/transport/mqtt/MQTTProtocolConverter.java
----------------------------------------------------------------------
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 d19a0b3..b816a32 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
@@ -94,6 +94,23 @@ public class MQTTProtocolConverter {
     }
 
     void sendToActiveMQ(Command command, ResponseHandler handler) {
+
+        // Lets intercept message send requests..
+        if( command instanceof ActiveMQMessage) {
+            ActiveMQMessage msg = (ActiveMQMessage) command;
+            if( msg.getDestination().getPhysicalName().startsWith("$") ) {
+                // We don't allow users to send to $ prefixed topics to avoid failing MQTT
3.1.1 spec requirements
+                if( handler!=null ) {
+                    try {
+                        handler.onResponse(this, new Response());
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                }
+                return;
+            }
+        }
+
         command.setCommandId(generateCommandId());
         if (handler != null) {
             command.setResponseRequired(true);


Mime
View raw message