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

This commit is contained in:
Hiram Chirino 2014-02-12 13:53:18 -05:00
parent 6e68a37115
commit 706830268e
1 changed files with 17 additions and 0 deletions

View File

@ -94,6 +94,23 @@ public class MQTTProtocolConverter {
} }
void sendToActiveMQ(Command command, ResponseHandler handler) { 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()); command.setCommandId(generateCommandId());
if (handler != null) { if (handler != null) {
command.setResponseRequired(true); command.setResponseRequired(true);