Example
The following examples can be found on this page:
Basic Settings Example
This example demonstrates how to use the Action Agent to publish curated temperature readings to an MQTT broker using minimal configuration. It is designed to work with the MQTT Listener Basic Settings Example.
Refer to configuration to understand all configuration options of this Agent.
Step 1: Add the Agent
Drag the MQTT Action Agent onto the canvas and rename it. Link the input endpoint to the temperature readings, the output endpoint to the printer, and save the Data Stream.
Step 2: Configure General
Select the Agent and click Configure. In this case, keep the default Collection.
Step 3: Configure Broker Connection
Fill in the broker address of your MQTT broker and the topic to listen for. In this case, tick to use variables, and select a broker address and topic.
Step 4: Configure Payload
Select the payload type and content to be published. In this case, leave the default payload type (Multi-Column JSON) and select the temperature and timestamp attributes as the payload.
Step 5: View Results
Apply the changes, save the Data Stream, and publish it.
Let's look at the Live Data View. Make sure the MQTT Listener Basic Settings Example is also published.
Observe that the curated temperature readings are printed, as well as the configured payload is published to the MQTT broker - and printed by the MQTT Listener too.
Files
See the Import, Export, and Clone - XMPro article for steps to import a Data Stream.
Advanced Settings Example
This example demonstrates how to use the Action Agent to publish curated temperature readings to an MQTT broker with a Secured channel using the Advanced Configuration.
Refer to configuration to understand all configuration options of this Agent.
Step 1: Add the Agent
Drag the MQTT Action Agent onto the canvas.
Link the input endpoint to the Temperature Data and the output endpoint to the printer.
Save the Data Stream.
Click Configure.
Step 2: Configure Broker Connection
Fill in the broker address of your MQTT broker and the topic to listen for. In this case, tick to use variables, select a broker address and topic and leave clean session ticked.
Tick the advanced settings to show more configuration options.
Step 3: Configure Advanced
Enter the port, client ID, QoS, post as batch, and status message preference.
In this example, select your port and client ID. Keep the default QoS (Exactly Once), batch option (ticked), and status message (unticked).
Step 4: Configure Channel
Tick the secure channel if you want to enable TLS/SSL channel communication and enter the channel details.
In this case, keep the default protocol (TSL v1.2), upload both the root and client certificates and select the client certificate password.
Step 5: Configure Authentication
Enter the authentication details: either anonymous or the username and password.
In this case, leave anonymous unticked and select a username and password.
Step 6: Configure Payload
Select the payload type and content to be published. In this case, leave the default payload type (Multi-Column JSON) and select the temperature and timestamp attributes as the payload.
Step 7: View Results
Apply the changes, save the Data Stream, and publish it.
Let's look at the Live Data View. Observe the curated temperature readings printed, as well as the configured payload published to the MQTT broker.
See Basic Settings Example for a side-by-side results with a Listener.
Files
See the Import, Export, and Clone - XMPro article for steps to import a Data Stream.
Last updated