MQ Telemetry Transport (MQTT) is a simple and lightweight network protocol for device communication. This is an easy to implement protocol that is based on the principle of publish/subscribe. These characteristics make MQTT ideal for use in constrained environments.
- When the network is expensive, has low bandwidth or is unreliable.
- When running on an embedded device with limited processor or memory resources.
The MQTT transport implementation requires an MQTT server instance to be able to send and receive messages. The recommended MQTT server is the Mosquitto message broker.
Configuration parameters for the MQTT receiver and sender are XML fragments that represent MQTT connection factories.
Following is a sample MQTT connection factory configuration that consists of four connection factory parameters:
MQTT connection factory parameters
Following are details on the MQTT parameters that you can set:
|The name of the host.|
A valid host name
|The port ID.||Yes|
|The client ID.||Yes||A valid client ID|
|The name of the topic||Yes||A valid topic name|
|The QoS value.||No|
|Whether session clean should be enabled or not.||No|
|Whether ssl should be enabled or not.||No|
|The username for the subscription.||No||A valid user name|
|The password for the subscription.||No||A valid password|
|The path of the directory to be used as the persistent data store for quality of service purposes.||No||A valid local path. The default value is the ESB temp path.|
|Whether blocking sender should be enabled or not.||No|
|The content type.||No||A valid content type. the default content type is |
For a sample that demonstrates how Axis2 publishes a message on a particular topic, and how an MQTT client subscribed to that topic receives it, see Sample 272:Publishing and Subscribing using WSO2 ESB's MQ Telemetry Transport.