Configuring the MQTT transport

The MQTT transport allows the probe to connect to and receive messages from an MQTT provider.

MQTT transport properties

The following table describes the properties used to configure the mqttTransport.properties file.
Table 1. MQTT transport properties

Property name

Description

connectionURL

Use this property to specify the URL of the MQTT bus provider.

The default is tcp://localhost:1883/.

clientId

Use this property to specify an ID for each MQTT client connection to the MQTT provider. The clientId of each MQTT client connection must be unique.

The default is MQTTClient.

topicName

Use this property to specify the name of a topic to subscribe to for messages. To subscribe to multiple topics, you can define multiple topic names.

The default is "".

Note: The MQTT wildcard character # can be used to define a wildcard set of topics to subscribe to. For example, a value of # would register interest in all topics known to the MQTT provider.

cleanStart

Use this property to specify whether or not the connection should perform a clean start.

The default is false.

If you specify a value of false, any message stored by the MQTT provider for a connection client ID will be returned on startup.

keepAlive

Use this property to specify the frequency (in seconds) with which the MQTT provider connection is polled during periods of inactivity. Polling keeps the connection alive and active.

The default is 30.

The following is an example of an MQTT properties file:
# Example format of MQTT properties file
# Uncomment the relevant lines and change the settings accordingly
#
# connectionURL - the URL of the MQTT provider
connectionURL=tcp://example.sbank.uk.ibm.com:1883
#
# clientId - the id to be used for this instance of an MQTT client 
# (must be unique for each client)
clientId=MQTTProbeClient
#
# topicName - name of a topic on which to subscribe for messages 
# (can be more than one)
topicName=topica
topicName=topicb
#
# cleanStart - true or false - decide whether to do a clean start 
# when reading messages
cleanStart=false
#
# keepAlive - duration, in seconds, to keep the connection alive 
# with no activity
keepAlive=30
#