Publishing a message to a specific MQTT v3 client
Publish a message from one MQTT v3 client to another, using ClientIdentifier as the topic name and IBM MQ as the publish/subscribe broker.
Before you begin
Do the task, Publishing a message to the MQTT client utility from IBM MQ Explorer. Leave the MQTT client utility connected.
About this task
The task demonstrates two things:
- Subscribing to a topic in one MQTT client, and receiving a publication from another MQTT client.
- Set up "point-to-point" subscriptions by using ClientIdentifier as the topic string.
Procedure
- Discard any existing subscriptions by disconnecting and reconnecting the MQTT client utility.
The subscription is discarded because, unless you change the defaults, the MQTT client utility connects with a clean session; see Clean sessions.
To make it easier to do the task, type your own ClientIdentifier, rather than use the generated ClientIdentifier created by the MQTT client utility.
- Click Disconnect to disconnect the MQTT client utility from the telemetry channel.
The Client History records a Disconnected event
- Change the Client Identifer to MyClient.
- Click Connect.
The Client History records a Connected event
- Create a subscription to the topic, MyClient
MyClient is the ClientIdentifier of this client.
- Type MyClient into the Subscription\Topic field> Subscribe.
The Client history records a Subscribed event.
- Start another MQTT client utility.
- Open the Queue Managers\QmgrName\Telemetry\channels folder.
- Right-click the PlainText channel> Run MQTT Client Utility...
- Click Connect.
The Client History records a Connected event
- Publish Hello MyClient! to the topic MyClient.
- Copy the subscription topic, MyClient, from the MQTT client utility running with the ClientIdentifier, MyClient.
- Paste MyClient into the Publication\Topic field of each of the MQTT client utility instances.
- Type Hello MyClient! into the Publication\message field.
- Click Publish in both instances.
Results
The Client history in the MQTT client utility with the ClientIdentifier, MyClient, records two Received events and one Published event. The other MQTT client utility instance records one Published event.
If you see only one Received event, check the following possible causes:
- Is the default transmission queue for the queue manager set to SYSTEM.MQTT.TRANSMIT.QUEUE ?
- Have you created queue manager aliases or remote queue definitions referencing MyClient in doing the other exercises? In case we have a configuration problem, delete any resources that reference MyClient, such as a queue manager aliases or transmission queues. Disconnect the client utilities, stop, and restart the telemetry (MQXR) service.