MQTT Inbound Endpoint¶
Introduction¶
MQ Telemetry Transport (MQTT) is a lightweight broker-based publish/subscribe messaging protocol, designed to be open, simple, lightweight and easy to implement. These characteristics make it ideal for use in constrained environments:
- Where the network is expensive, has low bandwidth, or is unreliable.
- When running on an embedded device with limited processor or memory resources.
Syntax¶
<inboundEndpoint xmlns="http://ws.apache.org/ns/synapse" name="Test" sequence="TestIn" onError="fault" protocol="mqtt" suspend="false">
<parameters>
<parameter name="sequential">true</parameter>
<parameter name="mqtt.connection.factory">mqttFactory</parameter>
<parameter name="mqtt.server.host.name">localhost</parameter>
<parameter name="mqtt.server.port">1883</parameter>
<parameter name="mqtt.topic.name">ei.test2</parameter>
<parameter name="mqtt.subscription.qos">2</parameter>
<parameter name="content.type">application/xml</parameter>
<parameter name="mqtt.session.clean">false</parameter>
<parameter name="mqtt.ssl.enable">false</parameter>
<parameter name="mqtt.subscription.username">client</parameter>
<parameter name="mqtt.subscription.password">e13</parameter>
<parameter name="mqtt.temporary.store.directory">m1y</parameter>
<parameter name="mqtt.reconnection.interval">5</parameter>
</parameters>
</inboundEndpoint>
Properties¶
Listed below are the properties used for creating an MQTT inbound endpiont.
Required Properties¶
The following properties are required when creating a MQTT inbound endpiont.
Property | Description |
---|---|
mqtt.connection.factory | Name of the connection factory. |
mqtt.server.host.name | Address of the message broker (eg., localhost). |
mqtt.server.port | Port of the message broker (e.g., 1883). |
mqtt.topic.name | MQTT topic to which the message should be published. |
content.type | The content type of the message, i.e., XML or JSON) |
coordination | This parameter is only applicable in a clustered environment. In a cluster environment an inbound endpoint will only be executed in worker nodes. If this parameter is set to true in a clustered environment, the inbound will only be executed in a single worker node. Once the running worker node is down, the inbound will start on another available worker node in the cluster. By default, this setting is true .
|
sequential | The behaviour when executing the given sequence. |
sequential | The behavior when executing the given sequence. When set as true , mediation will happen within the same thread. When set as false , the mediation engine will use the inbound thread pool. The default thread pool values can be found in the MI_HOME/conf/deployment.toml file, under the `[mediation]` section. The default setting is true .
|
Suspend |
If the inbound listener should pause when accepting incoming requests, set this to true . If the inbound listener should not pause when accepting incoming requests, set this to false .
|
Optional Properties¶
The following optional properties can be configured when creating an MQTT inbound endpiont.
Property | Description |
---|---|
mqtt.subscription.qos | The quality of service level that need to be maintained with the subscription. The quality of service level can be either 0,1 or 2. 0 - Specifying this level ensures that the message delivery is efficient. However, specifying this level does not guarantee that the message will be delivered to its recipient. 1 - Specifying this level ensures that the message is delivered at least once, but this can lead to messages being duplicated. 2 - This is the highest level of quality of service. Specifying this guarantees that the message is delivered and that it is delivered only once. |
mqtt.client.id | The id of the client. |
mqtt.session.clean | Whether the client and server should remember the state across restarts and reconnects. |
mqtt.ssl.enable | Whether to use TCP connection or SSL connection. |
mqtt.subscription.username | The username for the subscription. |
mqtt.subscription.password | The password for the subscription. |
mqtt.temporary.store.directory | Path of the directory to be used as the persistent data store for quality of service purposes. |
mqtt.reconnection.interval | The retry interval to reconnect to the MQTT server. |