Publishing and subscribing

If you cannot use the IBM® MQ Console to publish and subscribe to topics, you can run sample programs on an IBM MQ client instead.

The sample programs are the accessible method for publishing and subscribing to topics on the IBM MQ Appliance. The sample programs are located in MQ_INSTALLATION_PATH\Tools\c\samples\bin (Windows) and MQ_INSTALLATION_PATH/samp/bin (Linux). You can run the sample programs that are supplied with the client to publish and subscribe to topics.
To publish messages by using the sample program from the client system command line:
  1. Enter the command:
    amqspubc topic_name queue_manager_name
    
    For example:
    amqspubc mytopic test1
    
    The publisher connects to the queue manager named test1 and responds with the output, target topic is mytopic.
  2. Enter the messages that you want to publish to mytopic.

To subscribe to the topic by using the sample program:

  1. Open another command window and enter the command:
    amqssubc topic_name queue_manager_name
    
    For example:
    amqssubc mytopic test1
    
    The subscriber responds with the output, Calling MQGET : 30 seconds wait time. From now onwards, lines you type into the publisher appear in the output of the subscriber.
  2. Start another subscriber in another command window, and watch both subscribers receive publications.
Note: Remember to set the MQSERVER environment variable in each command window, as described in Setting up a queue manager to accept client connections.

Follow the related link for information on publishing and subscribing to topics from the IBM MQ Console.