Skip to main content

PublishMQTT

Description

Publishes a message to an MQTT topic

Tags

IOT, MQTT, publish

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 NameAPI NameDefault ValueAllowable ValuesDescription
Broker URI *Broker URIThe 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 Versionv3 AUTO
  • v3 AUTO
  • v5.0
  • v3.1.1
  • v3.1.0
The MQTT specification version when connecting with the broker. See the allowable value descriptions for more details.
UsernameUsernameUsername to use when connecting to the broker

Supports Expression Language, using Environment variables.
PasswordPasswordPassword to use when connecting to the broker
SSL Context ServiceSSL Context ServiceController Service:
SSLContextService

Implementations:
StandardRestrictedSSLContextService
StandardSSLContextService
The SSL Context Service used to provide client certificate information for TLS/SSL connections.
Session state *Session stateClean Session
  • Clean Session
  • Resume Session
Whether to start a fresh or resume previous flows. See the allowable value descriptions for more details.
Session Expiry IntervalSession Expiry Interval24 hrsAfter this interval the broker will expire the client and clear the session state.

This property is only considered if:
  • the property MQTT Specification Version has a value of 5
  • the property Session state has a value of false
Client IDClient IDMQTT client ID to use. If not set, a UUID will be generated.

Supports Expression Language, using Environment variables.
Topic *TopicThe topic to publish the message to.

Supports Expression Language, using FlowFile attributes and Environment variables.
Retain Message *Retain MessageWhether or not the retain flag should be set on the MQTT message.

Supports Expression Language, using FlowFile attributes and Environment variables.
Quality of Service (QoS) *Quality of Service(QoS)The Quality of Service (QoS) to send the message with. Accepts three values '0', '1' and '2'; '0' for 'at most once', '1' for 'at least once', '2' for 'exactly once'. Expression language is allowed in order to support publishing messages with different QoS but the end value of the property must be either '0', '1' or '2'.

Supports Expression Language, using FlowFile attributes and Environment variables.
Record Readerrecord-readerController Service:
RecordReaderFactory

Implementations:
AvroReader
CEFReader
CSVReader
ExcelReader
GrokReader
JsonPathReader
JsonTreeReader
ReaderLookup
ScriptedReader
Syslog5424Reader
SyslogReader
WindowsEventLogReader
XMLReader
YamlTreeReader
The Record Reader to use for parsing the incoming FlowFile into Records.
Record Writerrecord-writerController Service:
RecordSetWriterFactory

Implementations:
AvroRecordSetWriter
CSVRecordSetWriter
FreeFormTextRecordSetWriter
JsonRecordSetWriter
RecordSetWriterLookup
ScriptedRecordSetWriter
XMLRecordSetWriter
The Record Writer to use for serializing Records before publishing them as an MQTT Message.
Message Demarcatormessage-demarcatorWith this property, you have an option to publish multiple messages from a single FlowFile. This property allows you to provide a string (interpreted as UTF-8) to use for demarcating apart the FlowFile content. This is an optional property ; if not provided, and if not defining a Record Reader/Writer, each FlowFile will be published as a single message. 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)30Maximum 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)60Defines 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 MessageLast Will MessageThe message to send as the client's Last Will.
Last Will Topic *Last Will TopicThe topic to send the client's Last Will to.

This property is only considered if:
  • the property Last Will Message has a value specified
Last Will Retain *Last Will Retainfalse
  • true
  • false
Whether to retain the client's Last Will.

This property is only considered if:
  • the property Last Will Message has a value specified
Last Will QoS Level *Last Will QoS Level0 - At most once
  • 0 - At most once
  • 1 - At least once
  • 2 - Exactly once
QoS level to be used when publishing the Last Will Message.

This property is only considered if:
  • the property Last Will Message has a value specified

Dynamic Properties

This component does not support dynamic properties.

Relationships

NameDescription
failureFlowFiles that failed to send to the destination are transferred to this relationship.
successFlowFiles that are sent successfully to the destination are transferred to this relationship.

Reads Attributes

This processor does not read attributes.

Writes Attributes

This processor does not write attributes.

State Management

This component does not store state.

Restricted

This component is not restricted.

Input Requirement

This component requires an incoming relationship.

System Resource Considerations

ScopeDescription
MEMORYAn instance of this component can cause high usage of this system resource. Multiple instances or high concurrency settings may result a degradation of performance.

See Also

ConsumeMQTT