Running the Put sample programs
Running the amqsput and amqsputc samples
The amqqsput sample is the program for putting messages using local bindings, and the amqsputc sample is the program for putting using client bindings. These programs each take the following positional parameters:
- The name of the target queue (required)
- The name of the queue manager (optional)
If a queue manager is not specified, amqsput connects to the default queue manager and amqsputc connects to the queue manager identified by the MQSERVER environment variable or the client channel definition file.
- The open options (optional) If open options are not specified, the sample uses a value of 8208 which is the combination of these two options:
- MQOO_OUTPUT
- MQOO_FAIL_IF_QUIESCING
- The close options (optional)
If close options are not specified, the sample uses a value of 0 which is MQCO_NONE.
- The name of the target queue manager (optional)
If a target queue manager is not specified, the ObjectQMgrName field in the MQOD will be left blank.
- The name of the dynamic queue (optional)
If a dynamic queue name is not specified, the DynamicQName field in the MQOD will be left blank.
These programs also use an environment variable named MQSAMP_USER_ID which should be set to the user ID to be used for connection authentication. When this is set, the program will prompt for a password to accompany that user ID.
To run these programs, enter one of the following:
- amqsput myqueue qmanagername
- amqsputc myqueue qmanagername
where myqueue is the name of the queue on which the messages are going to be put, and qmanagername is the queue manager that owns myqueue.
Running the amq0put sample
The COBOL version does not have any parameters. It connects to the default queue manager and when you run it we are prompted:Please enter the name of the target queueIt takes input from StdIn and adds each line of input to the target queue. A blank line indicates there is no more data.
Running the AMQSPUT4 C sample ( IBM i)
The C program AMQSPUT4, available only for the IBM i platform, creates messages by reading data from a member of a source file.
We must specify the name of the file as a parameter when you start the program. The structure of the file must be:queue name text of message 1 text of message 2 ⋮ text of message n blank lineA sample of input for the put samples is supplied in library QMQMSAMP file AMQSDATA member PUT.
Note: Remember that queue names are case sensitive. All the queues created by the sample file create program AMQSAMP4 have names created in uppercase characters.The C program puts messages on the queue named in the first line of the file; we can use the supplied queue SYSTEM.SAMPLE.LOCAL. The program puts the text of each of the following lines of the file into separate datagram messages, and stops when it reads a blank line at the end of the file.
Using the example data file the command is:CALL PGM(QMQM/AMQSPUT4) PARM('QMQMSAMP/AMQSDATA(PUT)')
Running the AMQ0PUT4 COBOL sample ( IBM i)
The COBOL program AMQ0PUT4, available only on the IBM i platform, creates messages by accepting data from the keyboard.
To start the program, call the program and give the name of our target queue as a program parameter. The program accepts input from the keyboard into a buffer and creates a datagram message for each line of text. The program stops when you enter a blank line at the keyboard.
Parent topic: The Put sample programs