Sending a message to an MQTT client using IBM MQ Explorer

Send a message to the MQTT client utility by putting a message onto an IBM® MQ queue using IBM MQ Explorer. The task shows you how to configure a remote queue definition to send a message directly to an MQTT client.

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 sending a message to an MQTT client using queue rather than publishing to a topic. You do not create a subscription in the client. Step 2 of the task demonstrates that the previous subscription has been deleted.

Procedure

  1. 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.

    1. Click Disconnect to disconnect the MQTT client utility from the telemetry channel.

      The Client History records a Disconnected event

    2. Change the Client Identifer to MyClient.
    3. Click Connect.

    The Client History records a Connected event

  2. Check that the MQTT client utility no longer receives publication for the MQTTExampleTopic.
    1. Click the Queue Managers\QmgrName\Topics folder in the IBM MQ Explorer.
    2. Right-click MQTTExampleTopic > Test publication...
    3. Type Hello World! into the Message data field > Publish message > Switch to the MQTT Client Utility window.
    No event is recorded in the Client history.
  3. Create a remote queue definition for the client.

    Set the ClientIdentifier, MyClient, as the remote queue manager name in the remote queue definition. Use any name you like as the remote queue name. The remote queue name is passed to an MQTT client as the topic name.

    1. Right-click the Queue Managers\QmgrName\Queues folder> New > Remote queue definition.
    2. Name the definition, MyClientRemoteQueue > Next.
    3. Type MQTTExampleQueue in the Remote queue field.
    4. Type MyClient in the Remote queue manager field.
    5. Type SYSTEM.MQTT.TRANSMIT.QUEUE in the Transmission queue field > Finish.
  4. Put a test message onto MyClientRemoteQueue.
    1. Right-click MyClientRemoteQueue > Put test message...
    2. Type Hello queue! into the Message data field > Put message > Close

    The Client history records a Received event.

  5. Remove SYSTEM.MQTT.TRANSMIT.QUEUE as the default transmit queue.
    1. Right-click the Queue Managers\QmgrName folder > Properties...
    2. Click Communication in the navigator.
    3. Remove SYSTEM.MQTT.TRANSMIT.QUEUE from the Default transmission queue field > OK.
  6. Redo step 4.

    MyClientRemoteQueue is a remote queue definition that explicitly names the transmission queue. You do not need a to define default transmission queue to send a message to MyClient.

What to do next

With the default transmission queue no longer set to SYSTEM.MQTT.TRANSMIT.QUEUE, the MQTT Client Utility is unable to create a new subscription unless a queue manager alias is defined for the ClientIdentifier, MyClient. Restore the default transmission queue to SYSTEM.MQTT.TRANSMIT.QUEUE.