Publishing a message to the MQTT client utility from IBM MQ Explorer
Follow the steps in this task to publish a message using IBM MQ Explorer, and subscribe to it with the MQTT client utility. An additional task shows you how to configure a queue manager alias rather than setting the default transmission queue to SYSTEM.MQTT.TRANSMIT.QUEUE.
Before starting
The task assumes that we are familiar with IBM MQ and the IBM MQ Explorer, and that IBM MQ and MQ Telemetry feature are installed.
The user creating the queue manager resources for this task must have sufficient authority to do so. For demonstration purposes, the IBM MQ Explorer user ID is assumed to be member of the mqm group.
About this task
In the task, you create a topic in IBM MQ and subscribe to the topic using the MQTT client utility. When you publish to the topic using IBM MQ Explorer, the MQTT client receives the publication.Procedure
Do one of the following tasks:- We have installed MQ Telemetry, but you have not started it yet. Do the task: Start task with no telemetry (MQXR) service yet defined.
- We have run IBM MQ telemetry before, but want to use a new queue manager to do the demonstration. Do the task: Start task with no telemetry (MQXR) service yet defined.
- You want to do the task using an existing queue manager that has no telemetry resources
defined. You do not want to run the Define sample configuration wizard.
- Do one of the following tasks to set up telemetry:
- Configure a queue manager for telemetry on Linux and AIX
- Configure a queue manager for telemetry on Windows
- Do the task: Start task with a running telemetry (MQXR) service
- Do one of the following tasks to set up telemetry:
- To do the task using an existing queue manager that already has telemetry resources defined, do the task: Start task with a running telemetry (MQXR) service.
What to do next
Do Send a message to an MQTT client using IBM MQ Explorer to send a message directly to the client utility. Parent topic: Send a message to an MQTT clientStart task with no telemetry (MQXR) service yet defined
Create a queue manager and run the Define sample configuration to define sample telemetry resources for the queue manager. Publish a message using IBM MQ Explorer, and subscribe to it with the MQTT client utility.
About this task
When you set up sample telemetry resources using the Define sample configuration, the wizard sets the guest user ID permissions. Carefully consider if you want the guest user ID to be authorized in this way. guest on Windows, and nobody on Linux, are given permission to publish and subscribe to the root of the topic tree, and to put messages onto SYSTEM.MQTT.TRANSMIT.QUEUE.
The wizard also sets the default transmission queue to SYSTEM.MQTT.TRANSMIT.QUEUE, which might interfere with applications running on an existing queue manager. It is possible, but laborious, to configure telemetry and not use the default transmission queue; do the follow on task: Use a queue manager alias. In this task, you create a queue manager to avoid the possibility of interfering with any existing default transmission queue.
Procedure
-
Using IBM MQ Explorer, create and start a new queue
manager.
-
Right-click Queue Managers folder> New >
Queue manager .... Type a queue manager name >
Finish.
Make up a queue manager name; for example, MQTTQMGR.
-
Right-click Queue Managers folder> New >
Queue manager .... Type a queue manager name >
Finish.
-
Create and start the telemetry (MQXR) service and create a sample telemetry channel.
- Open the Queue Managers\QmgrName\Telemetry folder.
-
Click Define sample configuration... > Finish
Leave the Launch MQTT Client Utility check box checked.
-
Create a subscription for MQTT Example using the MQTT client utility.
-
Click Connect.
The Client history records a Connected event.
- Type MQTT Example into the Subscription\Topic field> Subscribe.
The Client history records a Subscribed event.
-
Click Connect.
-
Create MQTTExampleTopic in IBM MQ.
- Right-click the Queue Managers\QmgrName\Topics folder in the MQ Explorer> New > Topic.
- Type MQTTExampleTopic as the Name > Next.
- Type MQTT Example as the Topic string > Finish.
- Click OK to close the acknowledgment window.
-
Publish Hello World! to the topic MQTT Example using IBM MQ Explorer.
- Click the Queue Managers\QmgrName\Topics folder in the IBM MQ Explorer.
- Right-click MQTTExampleTopic > Test publication...
- Type Hello World! into the Message data field > Publish message > Switch to the MQTT Client Utility window.
The Client history records a Received event.
Create a telemetry channel and a topic. Authorize the user to use the topic and the
telemetry transmit queue. Publish a message using IBM MQ Explorer, and subscribe to it with the MQTT client utility. In this version of the task, a queue manager, QmgrName, is
defined and running. A telemetry (MQXR) service is defined and running. The telemetry (MQXR) service
might have been created manually, or by running the Define sample
configuration wizard. In this task you configure an existing queue manager to send a publication to the MQTT client utility. Step 1 of the task sets the default transmission
queue to SYSTEM.MQTT.TRANSMIT.QUEUE, which might interfere with applications
running on an existing queue manager. It is possible, but laborious, to configure telemetry and not
use the default transmission queue; do the follow on task: Use a queue manager alias.
The Client history records a Connected event.
The Client history records a Subscribed event.
The Client history records a Received event.
Publish a message to the MQTT client
utility using IBM MQ Explorer without setting the default
transmission queue to SYSTEM.MQTT.TRANSMIT.QUEUE. The task is a continuation of the previous task, and uses a queue manager alias to avoid setting
the default transmission queue to SYSTEM.MQTT.TRANSMIT.QUEUE. Complete either the task, Start task with no telemetry (MQXR) service yet defined or the task, Start task with a running telemetry (MQXR) service. When an MQTT client creates a subscription,
IBM MQ sends its response using
ClientIdentifier, as the remote queue manager name. In this task, it uses the
ClientIdentifier, MyClient. If there is no transmission queue or queue manager alias called MyClient,
the response is placed on the default transmission queue. By setting default transmission queue to
SYSTEM.MQTT.TRANSMIT.QUEUE, the MQTT client gets the response. We can avoid setting the default transmission queue to
SYSTEM.MQTT.TRANSMIT.QUEUE by using queue manager aliases. We must set up a queue
manager alias for every ClientIdentifier. Typically, there are too many clients to
make it practical to use queue manager aliases. Often ClientIdentifier is
unpredictable, making it impossible to configure telemetry this way. Nonetheless, in some circumstances you might have to configure the default transmission queue to
something other than SYSTEM.MQTT.TRANSMIT.QUEUE. The steps in Procedure configure a queue manager alias instead of
setting the default transmission queue to SYSTEM.MQTT.TRANSMIT.QUEUE.
The Client history records a Connected event.
The Client history records a Subscribe failed and a
Connection lost event.
The Client history records a Connected event. The Client history records a Connected event.
The Client history records a Subscribed event.
The Client history records a Received event.
Start task with a running telemetry (MQXR) service
Before starting
About this task
Procedure
setmqaut -m qMgrName -t topic -n MQTTExampleTopic -p User ID -all +pub +sub
setmqaut -m qMgrName -t q -n SYSTEM.MQTT.TRANSMIT.QUEUE -p User ID -all +put
Use a queue manager alias
Before starting
About this task
Procedure