API Docs - v3.0.1
Tested Siddhi Core version: 5.1.13
It could also support other Siddhi Core minor versions.
Sink
mqtt (Sink)
The MQTT sink publishes the events to an MQTT broker
Syntax@sink(type="mqtt", url="<STRING>", username="<STRING>", password="<STRING>", client.id="<STRING>", topic="<STRING>", quality.of.service="<STRING>", clean.session="<BOOL>", message.retain="<STRING>", keep.alive="<INT>", connection.timeout="<INT>", @map(...)))
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
url | The URL of the MQTT broker. It is used to connect to the MQTT broker It is required to specify a valid URL here. |
STRING | No | No | |
username | The username to be provided when the MQTT client is authenticated by the broker. |
null | STRING | Yes | No |
password | The password to be provided when the MQTT client is authenticated by the broker. |
empty | STRING | Yes | No |
client.id | A unique ID for the MQTT client. The server uses this to identify the client when it reconnects. If you do not specify a client ID, the system automatically generates it. |
generated by the system | STRING | Yes | No |
topic | The topic to which the events processed by WSO2 SP are published via MQTT. This is a mandatory parameter. |
STRING | No | Yes | |
quality.of.service | The quality of service provided by the MQTT client. The possible values are as follows. |
1 | STRING | Yes | Yes |
clean.session | This is an optional paramater. If this parameter is set to |
true | BOOL | Yes | No |
message.retain | If this parameter is set to true, the last message sent from the topic to which WSO2 SP publishes events is retained until the next message is sent. |
false | STRING | Yes | Yes |
keep.alive | The maximum number of seconds the connection between the MQTT client and the broker should be maintained without any events being transferred. Once this time interval elapses without any event transfers, the connection is dropped. The default value is 60. |
60 | INT | Yes | No |
connection.timeout | The maximum number of seconds that the MQTT client should spend attempting to connect to the MQTT broker. Once this time interval elapses, a timeout takes place. |
30 | INT | Yes | No |
Examples EXAMPLE 1
@sink(type='mqtt', url= 'tcp://localhost:1883', topic='mqtt_topic', clean.session='true', message.retain='false', quality.of.service= '1', keep.alive= '60',connection.timeout='30'@map(type='xml'))Define stream BarStream (symbol string, price float, volume long);
This query publishes events to a stream named BarStream
via the MQTT transport. The events are published to a topic named mqtt_topic located at tcp://localhost:1883.
Source
mqtt (Source)
The MQTT source receives the events from an MQTT broker
Syntax@source(type="mqtt", url="<STRING>", username="<STRING>", password="<STRING>", client.id="<STRING>", topic="<STRING>", quality.of.service="<STRING>", clean.session="<BOOL>", keep.alive="<INT>", connection.timeout="<INT>", @map(...)))
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
url | The URL of the MQTT broker. It is used to connect to the MQTT broker. It is required to specify a valid URL here. |
STRING | No | No | |
username | The username to be provided when the MQTT client is authenticated by the broker. |
null | STRING | Yes | No |
password | The password to be provided when the MQTT client is authenticated by the broker. |
empty | STRING | Yes | No |
client.id | A unique ID for the MQTT client. The server uses this to identify the client when it reconnects. If you do not specify a client ID, the system automatically generates it. |
STRING | No | No | |
topic | The topic from which WSO2 SP receives events via MQTT. Multiple topics can be specified as a list of comma separated values.This is a mandatory parameter. |
STRING | No | No | |
quality.of.service | The quality of service provided by the MQTT client. The possible values are as follows. |
1 | STRING | Yes | No |
clean.session | This is an optional paramater. If this parameter is set to |
true | BOOL | Yes | No |
keep.alive | The maximum number of seconds the connection between the MQTT client and the broker should be maintained without any events being transferred. Once this time interval elapses without any event transfers, the connection is dropped. The default value is 60. |
60 | INT | Yes | No |
connection.timeout | The maximum number of seconds that the MQTT client should spend attempting to connect to the MQTT broker. Once this time interval elapses, a timeout takes place. |
30 | INT | Yes | No |
Examples EXAMPLE 1
@source(type='mqtt', url= 'tcp://localhost:1883', topic='mqtt_topic', clean.session='true',quality.of.service= '1', keep.alive= '60',connection.timeout='30'@map(type='xml'))Define stream BarStream (symbol string, price float, volume long);
This query receives events from the mqtt_topic
topic via MQTT,and processes them to the BarStream stream.