MQ Telemetry Transport
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.
For example,
- 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:
<parameter locked="false" name="mqttConFactory"> <parameter locked="false" name="mqtt.server.host.name">localhost</parameter> <parameter locked="false" name="mqtt.server.port">1883</parameter> <parameter locked="false" name="mqtt.client.id">esb.test.listener</parameter> <parameter locked="false" name="mqtt.topic.name">esb.test2</parameter> </parameter>
MQTT connection factory parameters
Following are details on the MQTT parameters that you can set:
Parameter Name | Description | Required | Possible Values |
---|---|---|---|
mqtt.server.host.name | The name of the host. | Yes | A valid host name |
mqtt.server.port | The port ID. | Yes | 1883 ,1885 |
mqtt.client.id | The client ID. | Yes | A valid client ID |
mqtt.topic.name | The name of the topic | Yes | A valid topic name |
mqtt.subscription.qos | The QoS value. | No |
|
mqtt.session.clean | Whether session clean should be enabled or not. | No | true , false |
mqtt.ssl.enable | Whether ssl should be enabled or not. | No | true , false |
mqtt.subscription.username | The username for the subscription. | No | A valid user name |
mqtt.subscription.password | The password for the subscription. | No | A valid password |
mqtt.temporary.store.directory | 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. |
mqtt.blocking.sender | Whether blocking sender should be enabled or not. | No | true , false |
mqtt.content.type | The content type. | No | A valid content type. the default content type is text/plain . |
mqtt.message.retained | Whether the messaging engine should retain a published message or not. This parameter can be used only in the transport sender. | No | true , false The default value is false . |
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 /wiki/spaces/EI6xx/pages/49611158.