Transfer messages between the MQTT daemon for devices and IBM MQ

Do this task to learn how to send commands to the MQTT daemon for devices. The commands you write create a bridge that transfers messages from IBM® MQ to the daemon, and messages from the daemon to IBM MQ.

Before you begin

Note: The daemon for devices is no longer available. For an alternative solution, see the eclipse.org Mosquitto project (https://eclipse.org/mosquitto).

Do the tasks Publish a message to a specific MQTT v3 client and Using the MQTT daemon for devices as the publish/subscribe broker to become familiar with using the MQTT client utility. When you have finished the tasks, leave one instance of the MQTT client utility connected to the MQTT daemon for devices. Leave another instance connected to the telemetry channel.

The task presumes you have defined a channel to the telemetry service listening to port 1883 on address 127.0.0.1. Likewise, the default daemon listener is configured to listen to port 1884 on address 127.0.0.1. A single line in the configuration file, which is stored in the same directory as the daemon, configures the default daemon listener port.

port 1884

About this task

In this task, you update a running daemon to create a connection bridge to the IBM MQ telemetry (MQXR) service, and then exchange messages with the daemon.

Procedure

  1. Make sure that you have two instances of the MQTT client utility running. One is connected to the daemon on port 1884, and one is connected to the telemetry channel running on port 1883.
  2. Create the file, in the same directory as the daemon, with the following commands in the file.
    
    connection daemon1
    address 127.0.0.1:1883
    topic # in  import/ export/
    topic # out export/ import/
    try_private false
    
    • The bridge is called daemon1, and it connects to the channel configured for the telemetry (MQXR) service running at the socket address, 127.0.0.1:1883. The try_private command is optional; true is the default. Without this line, the bridge first tries to connect using a private protocol that is understood by the MQTT daemon for devices. Including try_private false in the commands avoids this step, and speeds up the time to finish a successful connection.
    • The line, topic # in import/ export/, instructs daemon1 to subscribe to all topics matching the topic string export/# created in the queue manager. It transfers the matching publications from the queue manager to the daemon, changing the start of the topic string from export/ to import/. The line, topic # out export/ import/, creates a subscription at the local daemon. The bridge subscribes to all topics matching the topic string export/# created in the daemon. It transfers publications from the daemon to the queue manager, changing the start of the topic string from export/ to import/.

    Figure 1 shows the resulting console log.

    Figure 1. Console log from starting connection bridge
    CWNAN0124I Starting bridge connection daemon1
    CWNAN0133I Bridge connection daemon1 to 127.0.0.1:1883 now established
    
  3. In each instance of the MQTT client utility, type import/# in the Subscription/Topic: input field > Subscribe.
  4. In each instance of the MQTT client utility, type export/# in the Publication/Topic: input field.
    1. In the MQTT client utility connected to port 1883, the telemetry channel, type From the queue manager in the Publication/Message: input field > Publish.
    2. In the MQTT client utility connected to port 1884, the MQTT daemon, type From the daemon in the Publication/Message: input field > Publish.

    The client history in each MQTT client utility shows the publication that has been transferred from one broker to the other.