The Distribution List sample amqsptl0 gives an example of putting a message on several message queues. It is based on the MQPUT sample, amqsput0.
The Distribution List sample runs in a similar way to the Put samples. It takes the following parameters:
These values are entered as pairs. For example:
amqsptl0 queue1 qmanagername1 queue2 qmanagername2
The queues are opened using MQOPEN and messages are put to the queues using MQPUT. Reason codes are returned if any of the queue or queue manager names are not recognized.
Remember to define channels between queue managers so that messages can flow between them. The sample program does not do that for you!
Put Message Records (MQPMRs) specify message attributes on a per destination basis. The sample chooses to provide values for MsgId and CorrelId, and these override the values specified in the MQMD structure.
The PutMsgRecFields field in the MQPMO structure indicates which fields are present in the MQPMRs:
MQLONG PutMsgRecFields=MQPMRF_MSG_ID + MQPMRF_CORREL_ID;
Next, the sample allocates the response records and object records. The object records (MQORs) require at least one pair of names and an even number of names, that is, ObjectName and ObjectQMgrName.
The next stage involves connecting to the queue managers using MQCONN. The sample attempts to connect to the queue manager associated with the first queue in the MQOR; if this fails, it goes through the object records in turn. You are informed if it is not possible to connect to any queue manager and the program exits.
The target queues are opened using MQOPEN and the message is put to these queues using MQPUT. Any problems and failures are reported in the response records (MQRRs).
Finally, the target queues are closed using MQCLOSE and the program disconnects from the queue manager using MQDISC. The same response records are used for each call stating the CompCode and Reason.