The MQTT binding in SwitchYard provides support for asynchronous communication with MQTT messaging providers. It supports both sides - service and reference. The MQTT binding is built on top of camel-mqtt and supports most of options for this endpoint. Please refer camel documentation for a detailed description of them.
Generic options
Following options can be aplied to <binding.mqtt> definition:
-
host : host to connect
-
localAddress : local address
-
connectAttemptsMax : The maximum number of connect attempts
-
reconnectAttemptsMax : The maximum number of reconnect attempts
-
reconnectDelay : The time in milliseconds between reconnect attempts
-
reconnectBackOffMultiplier : The multiplier to use to the delay between connection attempts
-
reconnectDelayMax : The maximum time in milliseconds between reconnect attempts
-
userName : user name
-
password : password
-
qualityOfService : The MQTT Quality of Service. Possible values are AtMostOnce, AtLeastOnce or ExactlyOnce
-
byDefaultRetain : The default retain policy
-
mqttTopicPropertyName : The property name for the MQTT topic
-
mqttRetainPropertyName : The property name for the MQTT Retain policy
-
mqttQosPropertyName : The property name for the MQTT Quality of Service
-
connectWaitInSeconds : Delay in seconds to wait for connection to be established
-
disconnectWaitInSeconds : Delay in seconds to wait for connection to be disconnected
-
sendWaitInSeconds : Delay in seconds to wait for the message to be sent
Binding Services with MQTT
Following option can be specified for MQTT service binding:
Here's an example of what a mqtt service binding looks like:
<sca:composite name="camel-mqtt-binding" targetNamespace="urn:switchyard-quickstart:camel-mqtt-binding:0.1.0">
<sca:service name="GreetingService" promote="GreetingService/GreetingService">
<mqtt:binding.mqtt name="Greet">
<mqtt:userName>karaf</mqtt:userName>
<mqtt:password>karaf</mqtt:password>
<mqtt:subscribeTopicName>camel/mqtt/test/input</mqtt:subscribeTopicName>
</mqtt:binding.mqtt>
</sca:service>
</sca:composite>
Binding References with MQTT
Following option can be specified for MQTT reference binding:
Here's an example of what a mqtt reference binding looks like:
<sca:composite name="camel-mqtt-binding" targetNamespace="urn:switchyard-quickstart:camel-mqtt-binding:0.1.0">
<sca:reference name="StoreReference" multiplicity="0..1" promote="GreetingService/StoreReference">
<mqtt:binding.mqtt name="Store">
<mqtt:userName>karaf</mqtt:userName>
<mqtt:password>karaf</mqtt:password>
<mqtt:publishTopicName>camel/mqtt/test/output</mqtt:publishTopicName>
</mqtt:binding.mqtt>
</sca:reference>
</sca:composite>