The Publish/Subscribe Sample
The Publish/Subscribe sample programs demonstrate the use of the publish and subscribe features in IBM® MQ.
There are four C and two COBOL programming language sample programs demonstrating how to program to the IBM MQ Publish/Subscribe interface. The programs are delivered in the C and COBOL language. The applications run in the batch environment; see Publish/Subscribe samples for the batch applications.
There are also COBOL samples that run in the CICS® environment; see The CICS Asynchronous Consumption and Publish/Subscribe sample.
Running the CSQ4BCP1 sample
This program is written in C, it publishes messages to a topic. Start one of the subscriber samples before running this program.
- The name of the target topic (required).
- The name of the queue manager (optional).
- Open options (optional).
- Close options (optional).
If a queue manager is not specified, CSQ4BCP1 connects to the default queue manager. There is a sample JCL to run the program, it resides in CSQ4BCPP.
Message content is provided through standard input ( SYSIN DD ).
Running the CSQ4BCP2 sample
This program is written in C, it subscribes to a topic and prints the messages received.
- The name of the target topic (required).
- The name of the queue manager (optional).
- MQSD subscription options (optional).
If a queue manager is not specified, CSQ4BCP2 connects to the default queue manager. There is a sample JCL to run the program, it resides in CSQ4BCPS.
Running the CSQ4BCP3 sample
This program is written in C, it subscribes to a topic using a user-specified destination queue and prints the messages received.
- The name of the target topic (required).
- The name of the destination (required).
- The name of the queue manager (optional).
- MQSD subscription options (optional).
If a queue manager is not specified, CSQ4BCP3 connects to the default queue manager. There is a sample JCL to run the program, it resides in CSQ4BCPD.
Running the CSQ4BCP4 sample
This program is written in C, it subscribes and gets messages from a topic allowing the use of extended options on the MQSUB call, extending those available on the simpler MQSUB sample: CSQ4BCP2. In addition to the message payload, message properties for each message is received and displayed.
- -t < string >: Topic string (required).
- -o < name >: Topic object name (required).
- -m < name >: Queue manager name (optional).
- -q < name >: Destination queue name (optional).
- -w < seconds >: Wait interval on MQGET in seconds (optional).
unlimited MQWI_UNLIMITED none No wait n Wait interval in seconds When no value is specified, the default is 30 seconds - -d < subname >: Create or resume named durable subscription (optional).
- -k: Keep durable subscription on MQCLOSE (optional).
If a queue manager is not specified, CSQ4BCP4 connects to the default queue manager. There is a sample JCL to run the program, it resides in CSQ4BCPE.
Running the CSQ4BVP1 sample
This program is written in COBOL, it publishes messages to a topic. Start one of the subscriber samples before running this program.
This program takes no parameters. SYSIN DD provides the input topic name, queue manager name, and message content.
If a queue manager is not specified, CSQ4BVP1 connects to the default queue manager. There is a sample JCL to run the program, it resides in CSQ4BVPP.
Running the CSQ4BVP2 sample
This program is written in COBOL, it subscribes to a topic and prints the messages received.
This program takes no parameters. SYSIN DD provides the input for topic name and queue manager name.
If a queue manager is not specified, CSQ4BVP1 connects to the default queue manager. There is a sample JCL to run the program, it resides in CSQ4BVPP.