ActiveMQ supports the MQTT protocol and will automatically map between JMS/NMS and MQTT clients. MQTT is a machine-to-machine (M2M) publish/subscribe messaging transport.
Please see the MQTT site for more details
Enabling the ActiveMQ Broker for MQTT
Its very easy to enable ActiveMQ for MQTT. Just add a connector to the broker using the MQTT URL.
<transportConnectors> <transportConnector name="matt" uri="mqtt://localhost:1883"/> </transportConnectors>
Security
The ActiveMQ MQTT Transport implementation fully supports an ActiveMQ security mechanism. Also, the authorization policies will be applied when you try to access (read/write) certain destinations.
Enabling MQTT over NIO
For better scalability (and performance) you might want to run the MQTT protocol over NIO transport. To do that just use mqtt+nio transport prefix instead of matt. For example, add the following transport configuration in your XML file
<transportConnector name="mqtt+nio" uri="mqtt+nio://localhost:1883"/>
This transport use NIO transport underneath and will generally use much less threads than standard connector.
Enabling MQTT over NIO + SSL
The MQTT transport also supports using NIO and SSL. To enable this option, use the mqtt+nio+ssl protocol - e.g.
<transportConnector name="mqtt+nio" uri="mqtt+nio+ssl://localhost:1883"/>
For more details on using SSL with ActiveMQ see the following article (How do I use SSL).
Working with Destinations with MQTT
MQTT supports hierarchies and wildcards, though the delimiters and characters are different: - Here's the mapping:
| function | ActiveMQ | MQTT |
|---|---|---|
| separator | . | / |
| element | * | # |
| sub tree | > | + |
These values are automatically transposed between clients using JMS/NMS/Stomp and clients using MQTTT. For example - a client subscribing to "/foo/#/bar" would receive messages published on a JMS Topic of foo.blah.bar.
Message transformations
MQTT messages are transformed into an JMS ByteMessage. Conversely, the body of any JMS Message is converted to a byte buffer to be the payload of an MQTT message.