ConsumeMQTT
Description
Subscribes to a topic and receives messages from an MQTT broker
Tags
IOT, MQTT, consume, listen, subscribe
Properties
In the list below required Properties are shown with an asterisk (*). Other properties are considered optional. The table also indicates any default values, and whether a property supports the NiFi Expression Language.
Display Name | API Name | Default Value | Allowable Values | Description |
---|---|---|---|---|
Broker URI * | Broker URI | The URI(s) to use to connect to the MQTT broker (e.g., tcp://localhost:1883). The 'tcp', 'ssl', 'ws' and 'wss' schemes are supported. In order to use 'ssl', the SSL Context Service property must be set. When a comma-separated URI list is set (e.g., tcp://localhost:1883,tcp://localhost:1884), the processor will use a round-robin algorithm to connect to the brokers on connection failure. Supports Expression Language, using Environment variables. | ||
MQTT Specification Version * | MQTT Specification Version | v3 AUTO |
| The MQTT specification version when connecting with the broker. See the allowable value descriptions for more details. |
Username | Username | Username to use when connecting to the broker Supports Expression Language, using Environment variables. | ||
Password | Password | Password to use when connecting to the broker | ||
SSL Context Service | SSL Context Service | Controller Service: SSLContextService Implementations: StandardRestrictedSSLContextService StandardSSLContextService | The SSL Context Service used to provide client certificate information for TLS/SSL connections. | |
Session state * | Session state | Clean Session |
| Whether to start a fresh or resume previous flows. See the allowable value descriptions for more details. |
Session Expiry Interval | Session Expiry Interval | 24 hrs | After this interval the broker will expire the client and clear the session state. This property is only considered if:
| |
Client ID | Client ID | MQTT client ID to use. If not set, a UUID will be generated. Supports Expression Language, using Environment variables. | ||
Group ID | Group ID | MQTT consumer group ID to use. If group ID not set, client will connect as individual consumer. | ||
Topic Filter * | Topic Filter | The MQTT topic filter to designate the topics to subscribe to. Supports Expression Language, using Environment variables. | ||
Quality of Service (QoS) * | Quality of Service(QoS) | 0 - At most once |
| The Quality of Service (QoS) to receive the message with. Accepts values '0', '1' or '2'; '0' for 'at most once', '1' for 'at least once', '2' for 'exactly once'. |
Record Reader | record-reader | Controller Service: RecordReaderFactory Implementations: AvroReader CEFReader CSVReader ExcelReader GrokReader JsonPathReader JsonTreeReader ReaderLookup ScriptedReader Syslog5424Reader SyslogReader WindowsEventLogReader XMLReader YamlTreeReader | The Record Reader to use for parsing received MQTT Messages into Records. | |
Record Writer | record-writer | Controller Service: RecordSetWriterFactory Implementations: AvroRecordSetWriter CSVRecordSetWriter FreeFormTextRecordSetWriter JsonRecordSetWriter RecordSetWriterLookup ScriptedRecordSetWriter XMLRecordSetWriter | The Record Writer to use for serializing Records before writing them to a FlowFile. | |
Add attributes as fields * | add-attributes-as-fields | true |
| If setting this property to true, default fields are going to be added in each record: _topic, _qos, _isDuplicate, _isRetained. This property is only considered if:
|
Message Demarcator | message-demarcator | With this property, you have an option to output FlowFiles which contains multiple messages. This property allows you to provide a string (interpreted as UTF-8) to use for demarcating apart multiple messages. This is an optional property ; if not provided, and if not defining a Record Reader/Writer, each message received will result in a single FlowFile. To enter special character such as 'new line' use CTRL+Enter or Shift+Enter depending on the OS. Supports Expression Language, using Environment variables. | ||
Connection Timeout (seconds) | Connection Timeout (seconds) | 30 | 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. | |
Keep Alive Interval (seconds) | Keep Alive Interval (seconds) | 60 | Defines the maximum time interval between messages sent or received. It enables the client to detect if the server is no longer available, without having to wait for the TCP/IP timeout. The client will ensure that at least one message travels across the network within each keep alive period. In the absence of a data-related message during the time period, the client sends a very small "ping" message, which the server will acknowledge. A value of 0 disables keepalive processing in the client. | |
Last Will Message | Last Will Message | The message to send as the client's Last Will. | ||
Last Will Topic * | Last Will Topic | The topic to send the client's Last Will to. This property is only considered if:
| ||
Last Will Retain * | Last Will Retain | false |
| Whether to retain the client's Last Will. This property is only considered if:
|
Last Will QoS Level * | Last Will QoS Level | 0 - At most once |
| QoS level to be used when publishing the Last Will Message. This property is only considered if:
|
Max Queue Size * | Max Queue Size | The MQTT messages are always being sent to subscribers on a topic regardless of how frequently the processor is scheduled to run. If the 'Run Schedule' is significantly behind the rate at which the messages are arriving to this processor, then a back up can occur in the internal queue of this processor. This property specifies the maximum number of messages this processor will hold in memory at one time in the internal queue. This data would be lost in case of a NiFi restart. |
Dynamic Properties
This component does not support dynamic properties.
Relationships
Name | Description |
---|---|
Message | The MQTT message output |
parse.failure | If a message cannot be parsed using the configured Record Reader, the contents of the message will be routed to this Relationship as its own individual FlowFile. |
Reads Attributes
This processor does not read attributes.
Writes Attributes
Name | Description |
---|---|
mqtt.broker | MQTT broker that was the message source |
mqtt.isDuplicate | Whether or not this message might be a duplicate of one which has already been received. |
mqtt.isRetained | Whether or not this message was from a current publisher, or was "retained" by the server as the last message published on the topic. |
mqtt.qos | The quality of service for this message. |
mqtt.topic | MQTT topic on which message was received |
record.count | The number of records received |
State Management
This component does not store state.
Restricted
This component is not restricted.
Input Requirement
This component does not allow an incoming relationship.
System Resource Considerations
Scope | Description |
---|---|
MEMORY | The 'Max Queue Size' specifies the maximum number of messages that can be hold in memory by NiFi by a single instance of this processor. A high value for this property could represent a lot of data being stored in memory. |