Putting messages to a distribution list
To put messages to a distribution list, you can use MQPUT or MQPUT1.
As input, you must supply:
- A connection handle (see Putting messages on a queue for a description).
- An object handle. If a distribution list is opened using MQOPEN,
the
Hobj
allows you only to put to the list. - A message descriptor structure (MQMD). See MQMD for a description of this structure.
- Control information in the form of a put-message option structure (MQPMO). See Specifying options using the MQPMO structure for information about completing the fields of the MQPMO structure.
- Control information in the form of Put Message Records (MQPMR).
- The length of the data contained within the message (MQLONG).
- The message data itself.
The output is:
- A completion code
- A reason code
- Response Records (optional)
Using the MQPMR structure
This structure is optional and gives destination-specific information for some fields that you might want to identify differently from those already identified in the MQMD.
For a description of these fields, see MQPMR.
The
content of each record depends on the information given in the
PutMsgRecFields
field
of the MQPMO. For example, in the sample program AMQSPTL0.C (see The Distribution List sample program for a description) showing the use of
distribution lists, the sample chooses to provide values for MsgId
and CorrelId
in
the MQPMR. This section of the sample program looks like this:
typedef struct
{
MQBYTE24 MsgId;
MQBYTE24 CorrelId;
} PutMsgRec;
...
/**********************
MQLONG PutMsgRecFields=MQPMRF_MSG_ID | MQPMRF_CORREL_ID;
This implies that MsgId
and CorrelId
are
provided for each destination of a distribution list. The Put Message
Records are provided as an array.
Figure 1 shows
how you can put a message to a distribution list in C.
Figure 2 shows how you
can put a message to a distribution list in COBOL.
Using MQPUT1
If
you are using MQPUT1, consider the following points:
- The values of the
ResponseRecOffset
andResponseRecPtr
fields must be null or zero. - The Response Records, if required, must be addressed from the MQOD.