The Put sample programs put messages on a queue using the MQPUT call. See Features demonstrated in the sample programs for the names of these programs.
These programs each take 2 parameters:
If a queue manager is not specified, amqsput connects to the default queue manager and amqsputc connects to the queue manager identified by an environment variable or the client channel definition file. 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.
This program has no visible interface; all messages are put in the output file.
This program takes 4 parameters:
To run amqsputw from the Windows program manager:
For example:
amqsputw outfile.out infile.in qmanagername myqueue
where:
outfile.out is used to hold the messages generated when the program runs.
infile.in contains the data to be put onto the target queue. Each line of data is put as a message. This must be an ASCII file.
qmanagername is the queue manager that owns myqueue.
myqueue is the name of the target queue on which the messages are going to be put. If you don't enter a queue name, the default queue for the queue manager is used.
Here is an example of what you would see in the output file if you supplied a target queue name:
Sample AMQSPUTW start Output file "OUTFILE.OUT" opened Input file "INFILE.IN" opened Queue Manager name "QMANAGERNAME" will be used target queue is MYQUEUE MQPUT OK - message contents: <AMQSPUTW: Windows Client Test Message 1> MQPUT OK - message contents: <AMQSPUTW: Windows Client Test Message 2> MQPUT OK - message contents: <AMQSPUTW: Windows Client Test Message 3> Sample AMQSPUTW end
Here is an example of what you would see in the output file if you did not enter a target queue name (for example, amqsputw outfil2.out c: \infil2.in qmanagernam2):
Sample AMQSPUTW start Output file "OUTFIL2.OUT" opened Input file "C:\INFIL2.IN" opened Queue Manager name "QMANAGERNAM2" will be used No parameter for Queue Name. Default Queue Name will be used target queue is QDEF2.Q MQPUT OK - message contents: <AMQSPUTW: Windows Client Test Message 1> MQPUT OK - message contents: <AMQSPUTW: Windows Client Test Message 2> MQPUT OK - message contents: <AMQSPUTW: Windows Client Test Message 3> Sample AMQSPUTW end
where QDEF2.Q is the name of the default queue for the queue manager.
It is important always to look in the output file to see what has happened as there is no visible indication of success or failure when you run this program.
The COBOL version does not have any parameters. It connects to the default queue manager and when you run it you are prompted:
Please enter the name of the target queue
It takes input from StdIn and adds each line of input to the target queue. A blank line indicates there is no more data.
The C program creates messages by reading data from a member of a source file. You 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 line
A sample of input for the put samples is supplied in library QMQMSAMP file AMQSDATA member PUT.
The C program puts messages on the queue named in the first line of the file--you could 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)')
The COBOL program creates messages by accepting data from the keyboard. To start the program, call the program and give the name of your 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.
The program uses the MQOPEN call with the MQOO_OUTPUT option to open the target queue for putting messages. If it cannot open the queue, the program outputs an error message containing the reason code returned by the MQOPEN call. To keep the program simple, on this and on subsequent MQI calls, the program uses default values for many of the options.
For each line of input, the program reads the text into a buffer and uses the MQPUT call to create a datagram message containing the text of that line. The program continues until either it reaches the end of the input or the MQPUT call fails. If the program reaches the end of the input, it closes the queue using the MQCLOSE call.