The Publish/Subscribe sample on z/OS

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 on z/OS.

This topic also provides information about how to run Publish/Subscribe sample programs. These sample programs include:


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.

This program takes up to four parameters:
  1. The name of the target topic string (required).
  2. The name of the queue manager (optional).
  3. Open options (optional).
  4. 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.

This program takes up to three parameters:
  1. The name of the target topic string (required).
  2. The name of the queue manager (optional).
  3. 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.

This program takes up to four parameters:
  1. The name of the target topic string (required).
  2. The name of the destination (required).
  3. The name of the queue manager (optional).
  4. 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 are received and displayed.

This program takes a variable set of parameters:

  • -t Topic string (required).
  • -o Topic object name (required).
  • -m Queue manager name (optional).
  • -q Destination queue name (optional).
  • -w Wait interval on MQGET in seconds (optional), where seconds can have any of the following values:

    • unlimited: MQWI_UNLIMITED
    • none: No wait
    • n: Wait interval in seconds
    • No value specified: When no value is specified, the default is 30 seconds

  • -d Subscription name (optional). Creates or resumes named durable subscription.
  • -k (optional). Keeps durable subscription on MQCLOSE.

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.

Parent topic: Use the sample programs for z/OS