This adapter allows you to subscribe to a topic publish messages in an MQTT broker.
The MQTT protocol provides a simple method of delivering messages via a publish/subscribe model. This makes it particularly suitable for messaging in the Internet of Things environment, such as low-power sensors or mobile devices such as phones, embedded computers or microcontrollers.
Note:
The MQTT Subscriber is usually used in conjunction with the MQTT Publisher.
Properties
|
|
Operation executed by the adapter Possible values:
|
Parameters
|
|
Adapter main class (do not change!) Possible values: de.softproject.integration.adapter. mqtt.MqttSubscriberAdapter: Main class (default) |
|
|
Broker alias Possible values:
The alias can be defined as an attribute of the |
|
|
Identifier for the client that subscribes to the broker Possible values:
The client ID can be defined within the |
|
|
Timeout for ONLINE_ON_DEMAND connections (for the Possible values: Integer greater than |
|
|
Connection mode selected to create the client. Depending on the selected value, the client connection is retained or is disconnected after a certain time ( Possible values:
This parameter is not required if |
|
|
Specifies whether the state between the client and the broker is state-oriented. Possible values: This parameter is not required if |
|
|
Path to the keystore. If no SSL/TLS configuration is required to connect to the broker, the parameter value can be empty. Possible values: File path This parameter is not required if |
|
|
Password to the keystore specified for Possible values: Any string This parameter is not required if |
|
|
Name of the topic the client subscribes to Possible values: Any string The topic can be defined for each broker in the |
|
|
Protocol, host, and port for connecting the client to the broker. Possible values:
This parameter is not required if |
|
|
Input format of the adapter Possible values:
|
|
|
Username used to connect to a broker requesting credentials. Possible values: User name This parameter is not required if |
|
|
Password used to connect to a broker who requires credentials. Possible values: Password This parameter is not required if |
|
|
Quality of service, for receiving messages when subscribing to a topic. Possible values:
This parameter is not required if |
|
|
Path to the process that runs each time a message from the subscribed topic is received Possible values: Process path in the format |
Status values
|
|
The operation was successful. |
|
|
There was an error while connecting, disconnecting, publishing, or subscribing. |
Input
The adapter does not expect any input document.
Output
The output corresponds to the input.
Configuration file
To define broker, client, SSL/TLS configurations, etc., a configuration file with a specified structure can be used, which is loaded at server startup. The mqttconfig.xml configuration file must be stored under the path X4DB/0. If the broker and client are defined in the configuration file, then only the values for alias and cliendId must be specified in the adapter parameters.
The file contains the following elements:
|
KeyStore |
The path and password of the keystore used to establish an SSL connection to the broker. If this optional element is not specified, a trust manager is created to accept all certificates. Both absolute and relative paths to the Example: Relative path specification
XML
Absolute path specification
XML
|
|---|---|
|
Broker |
MQTT server Relevant information is embedded in the
|
|
Topic |
Topic that can be subscribed to receive the published message. It has the following attributes:
|
Example configuration
<?xml version='1.0' encoding='UTF-8'?>
<RootElement>
<!-- Both, relative and absolute paths to X4DB/0 are allowed -->
<KeyStore password="password">C:/Users/MaxMustermann/Documents/MQTT/Keystore/application.keystore</KeyStore>
<Broker alias="Mosquitto_MQTT">
<Server>ssl://localhost:8883</Server>
<ClientId mode="ALWAYS_ONLINE_ON_STARTUP">C1</ClientId>
<ClientId mode="ALWAYS_ONLINE_ON_FIRST_PUBLISH">C2</ClientId>
<ClientId timeout="40" mode="ONLINE_ON_DEMAND">C3</ClientId>
<ClientId timeout="20" mode="ONLINE_ON_DEMAND">C4</ClientId>
<Topic filter="topic/action1" qos="AT_LEAST_ONCE">
<Process url="x4db://1/X4Experience/ESB/3-Reference/1-AdapterSuites/X4MQTTAdapter/Processes/TopicProcesses/ProcessTopic1.wrf"/>
</Topic>
<Topic filter="topic/action2" qos="AT_MOST_ONCE">
<Process url="x4db://1/X4Experience/ESB/3-Reference/1-AdapterSuites/X4MQTTAdapter/Processes/TopicProcesses/ProcessTopic2.wrf"/>
</Topic>
<Topic filter="topic/action1" qos="EXACTLY_ONCE">
<Process url="x4db://1/X4Experience/ESB/3-Reference/1-AdapterSuites/X4MQTTAdapter/Processes/TopicProcesses/ProcessTopic3.wrf"/>
</Topic>
</Broker>
</RootElement>