The Put sample programs put messages on a queue using the MQPUT
call.
The source programs are supplied in C and COBOL in the batch and CICS
environments (see Table 45 and Table 50).
The flow through the program logic is:
- Connect to the queue manager using the MQCONN call. If
this call fails, print the completion and reason codes and stop
processing.
- Note:
- If you are running the sample in a CICS environment, you do not need to issue
an MQCONN call; if you do, it returns DEF_HCONN. You can use the
connection handle MQHC_DEF_HCONN for the MQI calls that follow.
- Open the queue using the MQOPEN call with the MQOO_OUTPUT
option. 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.
- Create a loop within the program issuing MQPUT calls until the required
number of messages are put on the queue. If an MQPUT call fails, the
loop is abandoned early, no further MQPUT calls are attempted, and the
completion and reason codes are returned.
- 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.
- 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 you are running the sample in a CICS environment, you do not need to issue
an MQDISC call.
To run the samples, you must edit and run the sample JCL, as described in Preparing and running sample applications for the batch environment.
The programs take the following parameters in an EXEC PARM, separated by
spaces in C and commas in COBOL:
- The name of the queue manager (4 characters)
- The name of the target queue (48 characters)
- The number of messages (up to 4 digits)
- The padding character to be written in the message (1 character)
- The number of characters to write in the message (up to 4 digits)
- The persistence of the message (1 character: 'P' for
persistent or 'N' for nonpersistent)
If you enter any of the above parameters wrongly, you will receive
appropriate error messages.
Any messages from the samples are written to the SYSPRINT data set.
- To keep the samples simple, there are some minor functional differences
between language versions. However, these differences are minimized if
the layout of the parameters shown in the sample run JCL, CSQ4BCJR, and
CSQ4BVJR, is used. None of the differences relate to the MQI.
- CSQ4BCK1 allows you to enter more than four digits for the number of
messages sent and the length of the messages.
- For the two numeric fields, enter any digit between 1 and 9999. The
value you enter should be a positive number. For example, to put a
single message, you can enter 1 or 01 or 001 or 0001 as the value. If
you enter non-numeric or negative values, you may receive an error. For
example, if you enter '-1', the COBOL program will send a one-byte
message, but the C program will receive an error.
- For both programs, CSQ4BCK1 and CSQ4BVK1, you must enter 'P' in
the persistence parameter, ++PER++, if you require the message to be
persistent. If you fail to do so, the message will be
nonpersistent.
The transactions take the following parameters separated by commas:
- The number of messages (up to 4 digits)
- The padding character to be written in the message (1 character)
- The number of characters to write in the message (up to 4 digits)
- The persistence of the message (1 character: 'P' for
persistent or 'N' for nonpersistent)
- The name of the target queue (48 characters)
If you enter any of the above parameters wrongly, you will receive
appropriate error messages.
For the COBOL sample, invoke the Put sample in the CICS environment by
entering:
MVPT,9999,*,9999,P,QUEUE.NAME
For the C sample, invoke the Put sample in the CICS environment by
entering:
MCPT,9999,*,9999,P,QUEUE.NAME
Any messages from the samples are displayed on the screen.
- To keep the samples simple, there are some minor functional differences
between language versions. None of the differences relate to the
MQI.
- If you enter a queue name that is longer than 48 characters, its length is
truncated to the maximum of 48 characters but no error message is
returned.
- Before entering the transaction, press the 'CLEAR' key.
- For the two numeric fields, enter any number between 1 and 9999.
The value you enter should be a positive number. For example, to put a
single message, you can enter the value 1 or 01 or 001 or 0001. If you
enter non-numeric or negative values, you may receive an error. For
example, if you enter '-1', the COBOL program will send a 1 byte
message, and the C program will abend with an error from malloc().
- For both programs, CSQ4CCK1 and CSQ4CVK1, you must enter 'P' in
the persistence parameter, if you require the message to be persistent.
For non-persistent messages, enter 'N' in the persistence
parameter. If you enter any other value you will receive an error
message.
- The messages are put in syncpoint because default values are used for all
parameters except those set during program invocation.
© IBM Corporation 1993, 2002. All Rights Reserved