Publisher
Publisher
The Publisher is a Sequencer block, that can be used to publish data to the MQTT (Message Queue Telemetry Transport) network via Sequencer Events.
Publisher has no MQTT client functionality included in the block. Therefore, to be able to send MQTT data, Publisher has to be connected to a MQTTClient first, via the MQTTClient connector, as is shown in the following block diagram:
Note: There is a limitation: the Publisher and the MQTTClient it is connected to must reside inside of the same CDP application.
Publisher can be connected to MQTTClient also via the MQTTClientRPC router block(s). Routing via one or many MQTTClientRPC blocks can be handy when the Publisher and the MQTTClient are in different levels of application.
Events
Name | Input/Ouptut | Description |
---|---|---|
Connected | Output | Will be emitted when the MQTTClient has established the connection with the configured broker |
Disconnected | Output | Will be emitted when the MQTTClient has lost the connection with the configured broker |
Publish | Input | Invokes publishing of Payload data to the Topic. Can contain other arguments that modify the MQTT publishing behavior. |
Published | Output | Will be emitted when MQTTClient has successfully published the data from Publish event. Will contain all the arguments of the original Publish event plus a MessageID argument. |
PublishFailed | Output | Will be emitted when MQTTClient was not able to publish the data from Publish event. Will contain all the arguments of the original Publish event plus an Error argument. |
Arguments
Name | Description |
---|---|
Topic | MQTT topic string for the message to be published |
Payload | MQTT payload for the message to be published. |
QoS | Quality of service level of broker communication. Possible values are 0 (Deliver at most once), 1 (Deliver at least once) or 2 (Deliver exactly once). |
Retain | Defines if the broker should retain the last message sent. If true, then for any new subscriber on this topic, the retained message will be sent immediately. |
AutoAlias | Generate MQTT v5 topic alias on first publish to save network traffic on consequent sends when the same Topic string is used. Can be used only when MQTTClient ProtocolVersion is set to v5 (or higher) and the broker also supports MQTT v5 (or higher). |
ResponseTopic | When filled, indicates a topic that the request publisher expects the response to be published to. Can be used only when MQTTClient ProtocolVersion is set to v5 (or higher) and the broker also supports MQTT v5 (or higher). |
CorrelationData | When filled, identifies the specific request and should be echoed back by repsonder when it responds to the ResponseTopic. Can be used only when MQTTClient ProtocolVersion is set to v5 (or higher) and the broker also supports MQTT v5 (or higher). |
MessageID | On successful publish (Published event), contains MQTT message ID of the outgoing message. MessageID is available only when QoS > 0. |
Error | On failure (PublishFailed event), contains the error message describing the failure reason |
Properties
Name | Description |
---|---|
PendingCount | Pending Publish events - i.e. events with no Publised or PublishFailed response from MQTTClient |
Note: When you need to publish Payloads, which can contain non-printable or zero characters, you have to set the Command attribute of Publish event to any value other than CM_TEXTCOMMAND (`20100_16`), that will instruct the CDP to receive the event data in binary form. Make sure you set the Command attribute to the very same value on the event sender side. Also, make sure that the argument order is exactly the same on the event sender side.
See also Subscriber and MQTTClient.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.