Writing publisher applications

Get started with writing publisher applications by studying two examples. The first is modeled as closely as possible on a point to point application putting messages on a queue, and the second demonstrates creating topics dynamically - a more common pattern for publisher applications.

Writing a simple IBM MQ publisher application is just like writing an IBM MQ point to point application that puts messages to a queue (Table 1). The difference is you MQPUT messages to a topic, not to a queue.

Step Point to point MQ Call Publish MQ Call
Connect to a queue manager MQCONN MQCONN
Open queue MQOPEN  
Open topic   MQOPEN
Put message(s) MQPUT MQPUT
Close topic   MQCLOSE
Close queue MQCLOSE  
Disconnect from queue manager MQDISC MQDISC
To make that concrete, there are two examples of applications to publish stock prices. In the first example (Example 1: Publisher to a fixed topic), that is modeled closely on putting messages to a queue, the administrator creates a topic definition in a similar way to creating a queue. The programmer codes MQPUT to write messages to the topic instead of writing them to a queue. In the second example (Example 2: Publisher to a variable topic), the pattern of interaction of the program with IBM MQ is similar. The difference is the programmer provides the topic to which the message is written, rather than the administrator. In practice this typically means that the topic string is content defined, or provided by another source, such as human input through a browser.

Parent topic: Writing publish/subscribe applications


Related concepts


Related information