
MQTT Subscribe
CertifiedSubscribe and buffer MQTT messages
MQTT Subscribe
Subscribe and buffer MQTT messages
Subscribes to one or more MQTT topics, writes received messages to internal storage, and returns the uri plus messagesCount. Stops when maxRecords or maxDuration is reached; defaults to JSON payloads with QoS 1.
type: io.kestra.plugin.mqtt.SubscribeExamples
id: mqtt_subscribe
namespace: company.team
tasks:
- id: subscribe
type: io.kestra.plugin.mqtt.Subscribe
server: tcp://localhost:1883
clientId: kestraProducer
qos: 1
maxDuration: 30s
topic:
- kestra/sensors/cpu
- kestra/sensors/mem
serdeType: JSON
maxRecords: 10
Subscribe to MQTT topics over TLS
id: mqtt_subscribe_ssl
namespace: company.team
tasks:
- id: subscribe
type: io.kestra.plugin.mqtt.Subscribe
server: ssl://localhost:8883
clientId: kestraProducer
qos: 2
maxDuration: 1m
topic:
- kestra/sensors/cpu
- kestra/sensors/mem
crt: "{{ secret('MQTT_CA_CERT') }}"
serdeType: JSON
maxRecords: 10
Properties
clientId *Requiredstring
A client identifier that is unique on the server being connected to
A client identifier clientId must be specified and be less that 65535 characters. It must be unique across all clients connecting to the same server. The clientId is used by the server to store data related to the client, hence it is important that the clientId remain the same when connecting to a server if durable subscriptions or reliable messaging are required. As the client identifier is used by the server to identify a client when it reconnects, the client must use the same identifier between connections if durable subscriptions or reliable delivery of messages is required.
server *Requiredstring
The address of the server to connect to, specified as a URI
The serverURI parameter is typically used with the the clientId parameter to form a key. The key is used to store and reference messages while they are being delivered.
The address of the server to connect to is specified as a URI. Two types of connection are supported tcp:// for a TCP connection and ssl:// for a TCP connection secured by SSL/TLS. For example:
tcp://localhost: 1883ssl://localhost: 8883If the port is not specified, it will default to 1883 fortcp://" URIs, and 8883 forssl://URIs.
topic *RequiredNon-dynamicobject
Topics to consume
String or list of strings; when multiple topics are provided they are all subscribed.
authMethod string
The Authentication Method
Only available if version = V5
If set, this value contains the name of the authentication method to be used for extended authentication. If null, extended authentication is not performed.
connectionTimeout string
The connection timeout
This value defines the maximum time interval the client will wait for the network connection to the MQTT server to be established. The default timeout is 30 seconds. A value of 0 disables timeout processing meaning the client will wait until the network connection is made successfully or fails.
crt string
CA certificate for TLS connections
The CA certificate used to verify the MQTT broker's server certificate when connecting over TLS (ssl://).
Accepts one of the following formats:
- PEM content: the full PEM-encoded certificate string (e.g. from
{{ secret('MQTT_CA_CERT') }}) - Kestra internal storage URI: a
kestra://URI pointing to a certificate file from a previous task output - Local file path: an absolute path to a certificate file on the Kestra worker filesystem
httpsHostnameVerificationEnabled booleanstring
Disable ssl verification
This value will allow all ca certificate.
maxDuration string
The max duration waiting for new rows
It's not an hard limit and is evaluated every second
maxRecords integerstring
The max number of rows to fetch before stopping
It's not an hard limit and is evaluated every second
mqttVersion string
V5V3V5The MQTT version to use
password string
The password to use for the connection
pluginDefaultsRef Non-dynamicstring
Reference (ref) of the pluginDefaults to apply to this task.
qos integerstring
1Sets the quality of service for this message
- Quality of Service 0: indicates that a message should be delivered at most once (zero or one times). The message will not be persisted to disk, and will not be acknowledged across the network. This QoS is the fastest, but should only be used for messages which are not valuable - note that if the server cannot process the message (for example, there is an authorization problem). Also known as "fire and forget".
- Quality of Service 1: indicates that a message should be delivered at least once (one or more times). The message can only be delivered safely if it can be persisted, so the application must supply a means of persistence using MqttConnectOptions. If a persistence mechanism is not specified, the message will not be delivered in the event of a client failure. The message will be acknowledged across the network.
- Quality of Service 2: indicates that a message should be delivered once. The message will be persisted to disk, and will be subject to a two-phase acknowledgement across the network. The message can only be delivered safely if it can be persisted, so the application must supply a means of persistence using MqttConnectOptions. If a persistence mechanism is not specified, the message will not be delivered in the event of a client failure. If persistence is not configured, QoS 1 and 2 messages will still be delivered in the event of a network or server problem as the client will hold state in memory. If the MQTT client is shutdown or fails and persistence is not configured then delivery of QoS 1 and 2 messages can not be maintained as client-side state will be lost.
serdeType string
JSONSTRINGJSONBYTESSerializer / Deserializer used for the payload
username string
The user name to use for the connection
Outputs
messagesCount integer
Number of messages consumed
uri string
uriURI of the internal storage file