MQTT element

IBMStreams com.ibm.streamsx.messaging Toolkit > com.ibm.streamsx.messaging 5.4.3 > Connection specifications document > Connection_specification element > MQTT element

The <MQTT> element specifies the information that is needed by the MQTTSink and MQTTSource operators to establish a connection with MQTT-based messaging systems.

The following example shows a <connection_specification> element that contains an <MQTT> element:

<connection_specifications>
  <connection_specification name="mqttconn">
    <MQTT serverURI="ssl://hostname:1883" trustStore="etc/trustFile.jks"/>
  </connection_specification>
</connection_specifications>
The <MQTT> element has the following attributes:
  • keyStorePassword
    • This optional attribute specifies the password for the keystore file. This attribute is specified when the keyStore attribute is specified and the keystore file it is protected by a password. If the keyStorePassword is invalid the operator terminates.
  • keyStore
    • This optional attribute specifies the name of the keystore file, which is in one of the supported format by the JDK being used. The keystore file must contain the public certificate and the private key of the MQTT server that you want to connect to. If the keystore file does not exist, the operator terminates. The location of the keystore file can be absolute path or a path that is relative to the application directory.
  • serverURI
    • This required attribute specifies the URI of the MQTT server that you want to connect to. The serverURI has the following format: protocol://hostname or IP address:portnumber
    • The supported protocols are SSL and TCP. By default, the protocol is set to tcp, and the operators use the TCP protocol to connect to an MQTT server.
    • To use SSL authentication, set the protocol to ssl. You must also specify a value for the following attributes based on the type of SSL authentication:
      • For client SSL authentication, if a password is set for the keystore, set the keyStore and keyStorePassword attributes in the MQTT element.
      • For server SSL authentication, set the trustStore attribute in the MQTT element.
      • For mutual SSL authentication, if a password is set for the keystore, set the trustStore, keyStore, and keyStorePassword attributes in the MQTT element.
    • If you do not set the appropriate attributes, a run time error occurs.
  • trustStore
    • This optional attribute specifies the name of the truststore file, which is in one of the supported format by the JDK being used. You can specify an absolute path or a path that is relative to the application directory. The truststore file must contain the public certificates of all the trusted MQTT servers. If the truststore does not contain a public certificate for an MQTT server, the connection to that server is terminated.