Running the Put sample programs

[AIX, Linux, Windows]

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 messages using client bindings. These programs each take the following positional parameters:
  1. The name of the target queue (required)
  2. 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.

  3. 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
  4. The close options (optional)

    If close options are not specified, the sample uses a value of 0 which is MQCO_NONE.

  5. 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.

  6. 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.

Use the following environment variables to supply credentials that are used to authenticate with the queue manager:
MQSAMP_USER_ID
Set to the user ID to be used for connection authentication, if you want use a user ID and a password to authenticate with the queue manager. The program prompts for the password to accompany the user ID.
[AIX][MQ 9.3.4 Oct 2023][Linux]MQSAMP_TOKEN
Set to a non-blank value if you want to supply an authentication token to authenticate with the queue manager. The program prompts for the authentication token. Authentication tokens can be used only by the amqsputc sample that uses client bindings.
To run these programs, enter one of the following commands:
  • 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.
[AIX, Linux, Windows]

Running the amq0put sample

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.

[IBM i]

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.

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.

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; you 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)')
[IBM i]

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 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.