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
Its very easy to enable ActiveMQ for MQTT. Just add a connector to the broker using the MQTT URL.
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.
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
This transport use NIO transport underneath and will generally use much less threads than standard connector.
The MQTT transport also supports using NIO and SSL. To enable this option, use the mqtt+nio+ssl protocol - e.g.
MQTT supports hierarchies and wildcards, though the delimiters and characters are different: - Here's the mapping:
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.
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.
When a client connects, it will send a keep-alive duration, usually defaulting to 10s. ActiveMQ will honor the keep-alive duration by setting up an Inactivity Monitor that allows a grace period of 1.5 * duration. After that grace period duration elapses a connection could be closed if there is no activity. A broker receiving a PINGREQ and sending PINGRESP is considered activity to keep the connection opened.
If a client sends a keep-alive value of 0, ActiveMQ will not set up an Inactivity Monitor and connections will not be auto-shutdown due to inactivity. This however can lead to potentially leaky connections, so a default keep alive can be set on the server side (by an admin, for example) to not allow inactive connections to hang. This default keep alive would only be used if specified and if the client requests a keep-alive value of 0. The unit for the keep-alive value is milliseconds.
To enable a default, server-side MQTT keep alive: