The Put sample programs

 

 

amqsput and amqsputc

The amqsput and amqsputc put messages on a queue using the MQPUT call. amqsput can only be run locally, i.e., on the same box on which the MQ server is running. amqsputc can be run from anywhere within the network, and uses channels to communication with an MQ listener on another box in the network.

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.

Sample usage for amqsput:

amqsput queue_name queue_mgr_name

Sample usage for amqsputc

export PATH=/opt/mqm/samp/bin:/opt/mqm/bin:$PATH
export MQSERVER=channelname/TCP/'MQHost(MQPort)'
amqsputc queuename queue_mgr_name

Use amqsget and amqsgetc to retrieve the messages from the queue.

If you have active message-driven beans using the WebSphere message listener service, meaning that listener ports are tied to your queues and are turned on, then the amqsput and amqsputc programs will work, but the MDBs will pick up your messages right away, and amqsqet and amqsgetc will not find any messages on the queue. Turn off the listener ports first before testing.

 

amqsput4

Creates messages by reading data from a file. Specify filename as a parameter when running. The structure of the file must be:

   
queue name
text of message 1
text of message 2
...
text of message n
blank line

Sample input can be found in library QMQMSAMP file AMQSDATA.

Messages are put to the queue named in the first line of the file. For testing purposes you can use queue SYSTEM.SAMPLE.LOCAL. The program puts each line of text into separate datagram messages, and stops when it reads a blank line at the end of the file.

Usage:

CALL PGM(QMQM/AMQSPUT4) PARM('QMQMSAMP/AMQSDATA(PUT)')

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.

 

WebSphere is a trademark of the IBM Corporation in the United States, other countries, or both.

 

IBM is a trademark of the IBM Corporation in the United States, other countries, or both.