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 using 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 and rename it. Link the input endpoint to the temperature rata, 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, select a broker address and topic and leave clean session ticked.

Tick the advanced settings to show more configuration options.

Step 4: Configure Advanced

Enter advanced settings for the MQTT broker. Select a Port, and Client ID. And then leave QoS (Exactly Once) and Post as Batch (ticked) as Default.

Enter the port, client ID, QoS, and post as batch preference. In this example, select your port and client ID. Keep the default QoS (Exactly Once) and batch option (ticked).

Step 5: 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 6: 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 7: 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 8: 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