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.
- For information on running sample programs on a client that connects to a queue manager on an IBM MQ Appliance, see Setting up a queue manager to accept client connections.
- For detailed information on using the publish/subscribe sample programs, see The Publish/Subscribe sample programs in the IBM MQ documentation.
To publish messages by using the sample program from the client system command line:
- Enter the
command:
For example:amqspubc topic_name queue_manager_name
The publisher connects to the queue manager named test1 and responds with the output,amqspubc mytopic test1target topic is mytopic. - Enter the messages that you want to publish to
mytopic.
To subscribe to the topic by using the sample program:
- Open another command window and enter the
command:
For example:amqssubc topic_name queue_manager_name
The subscriber responds with the output,amqssubc mytopic test1Calling MQGET : 30 seconds wait time. From now onwards, lines you type into the publisher appear in the output of the subscriber. - 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.