+

Search Tips | Advanced Search

Design of the Get sample on z/OS

Learn about the design of the Get sample, and some usage notes to consider.

The flow through the program logic is:
  1. Connect to the queue manager using the MQCONN call. If this call fails, print the completion and reason codes and stop processing. Note: If we are running the sample in a CICS environment, we do not need to issue an MQCONN call; if you do, it returns DEF_HCONN. We can use the connection handle MQHC_DEF_HCONN for the MQI calls that follow.
  2. Open the queue using the MQOPEN call with the MQOO_INPUT_SHARED and MQOO_BROWSE options. On input to this call, the program uses the connection handle that is returned in step 1. For the object descriptor structure (MQOD), it uses the default values for all fields except the queue name field, which is passed as a parameter to the program. If the MQOPEN call fails, print the completion and reason codes and stop processing.
  3. Create a loop within the program issuing MQGET calls until the required number of messages are retrieved from the queue. If an MQGET call fails, the loop is abandoned early, no further MQGET calls are attempted, and the completion and reason codes are returned. The following options are specified on the MQGET call:

    • MQGMO_NO_WAIT
    • MQGMO_ACCEPT_TRUNCATED_MESSAGE
    • MQGMO_SYNCPOINT or MQGMO_NO_SYNCPOINT
    • MQGMO_BROWSE_FIRST and MQGMO_BROWSE_NEXT

    For a description of these options, see MQGET. For each message, the message number is printed followed by the length of the message and the message data.

  4. Close the queue using the MQCLOSE call with the object handle returned in step 2. If this call fails, print the completion and reason codes.
  5. Disconnect from the queue manager using the MQDISC call with the connection handle returned in step 1. If this call fails, print the completion and reason codes. Note: If we are running the sample in a CICS environment, we do not need to issue an MQDISC call.


Usage notes

  • To keep the samples simple, there are some minor functional differences between language versions. However, these differences are minimized if we use the layout of the parameters shown in the sample run JCL, CSQ4BCJR, and CSQ4BVJR,. None of the differences relate to the MQI.
  • CSQ4BCJ1 allows you to enter more than four digits for the number of messages retrieved.
  • Messages longer than 64 KB are truncated.
  • CSQ4BCJ1 can only correctly display character messages because it only displays until the first NULL (\0) character is displayed.
  • For the numeric number-of-messages field, enter any digit in the range 1 through 9999. The value that you enter should be a positive number. For example, to get a single message, we can enter 1, 01, 001, or 0001 as the value. If you enter nonnumeric or negative values, you might receive an error. For example, if you enter -1, the COBOL program retrieves one message, but the C program does not retrieve any messages.
  • For both programs, CSQ4BCJ1 and CSQ4BVJ1, enter B in the get parameter, ++GET++, if we want to browse the messages.
  • For both programs, CSQ4BCJ1 and CSQ4BVJ1, enter S in the syncpoint parameter, ++SYNC++, for messages to be retrieved in syncpoint.

Parent topic: The Get samples on z/OS

Last updated: 2020-10-04