Distribution lists

Not supported in WebSphere MQ for z/OS.

Distribution lists allow you to put a message to multiple destinations in a single MQPUT or MQPUT1 call. Multiple queues can be opened using a single MQOPEN and a message can then be put to each of those queues using a single MQPUT. Some generic information from the MQI structures used for this process can be superseded by specific information relating to the individual destinations included in the distribution list.

When an MQOPEN call is issued, generic information is taken from the Object Descriptor (MQOD). If you specify MQOD_VERSION_2 in the Version field and a value greater than zero in the RecsPresent field, the Hobj can be defined as a handle of a list (of one or more queues) rather than of a queue. In this case, specific information is given through the object records (MQORs), which give details of destination (that is, ObjectName and ObjectQMgrName).

The object handle (Hobj) is passed to the MQPUT call, allowing you to put to a list rather than to a single queue.

When a message is put on the queues (MQPUT), generic information is taken from the Put Message Option structure (MQPMO) and the Message Descriptor (MQMD). Specific information is given in the form of Put Message Records (MQPMRs).

Response Records (MQRR) can receive a completion code and reason code specific to each destination queue.

Figure 5 shows how distribution lists work.

Figure 5. How distribution lists work. This diagram shows that one message is transmitted through the channel and can be put on more than one remote queue.

The diagram shows two systems called Local and Remote. WebSphere MQ has been configured on each. On Local, there are two local queues called Local1 and Local2. On Remote there are two queues called Remote1 and Remote2. By configuring MQORs to create a distribution list, the diagram shows how one message put on Local is sent to the different queues and queue managers identified in the MQORs. Although the two queues on Remote are both included in the distribution list, only one message is actually transmitted across the channel connecting the two systems.

Opening distribution lists

Use the MQOPEN call to open a distribution list, and use the options of the call to specify what you want to do with the list.

As input to MQOPEN, you must supply:

The output from MQOPEN is:

Using the MQOD structure

Use the MQOD structure to identify the queues you want to open. To define a distribution list, you must specify MQOD_VERSION_2 in the Version field, a value greater than zero in the RecsPresent field, and MQOT_Q in the ObjectType field. See WebSphere MQ Application Programming Reference for a description of all the fields of the MQOD structure.

Using the MQOR structure

An MQOR structure must be provided for each destination. The structure contains the destination queue and queue manager names. The ObjectName and ObjectQMgrName fields in the MQOD are not used for distribution lists. There must be one or more object records. If the ObjectQMgrName is left blank, the local queue manager is used. See WebSphere MQ Application Programming Reference for further information about these fields.

You can specify the destination queues in two ways:

Whichever technique is chosen, one of ObjectRecOffset and ObjectRecPtr must be used; the call fails with reason code MQRC_OBJECT_RECORDS_ERROR if both are zero, or both are nonzero.

Using the MQRR structure

These structures are destination specific as each Response Record contains a CompCode and Reason field for each queue of a distribution list. You must use this structure to enable you to distinguish where any problems lie.

For example, if you receive a reason code of MQRC_MULTIPLE_REASONS and your distribution list contains five destination queues, you will not know which queues the problems apply to if you do not use this structure. However, if you have a completion code and reason code for each destination, you can locate the errors more easily.

See WebSphere MQ Application Programming Reference for further information about the MQRR structure.

Figure 6 shows how you can open a distribution list in C.

Figure 6. Opening a distribution list in C. The MQOD uses pointers to the MQOR and MQRR structures.

The diagram shows an MQOD (Object Descriptor) data structure. The version number is identified as 2. The structure contains   The number of MQOR and MQRR entries A pointer to a separate MQOR (Object Record) structure A pointer to a separate MQRR (Response Record) structure.   These structures are also shown, and each contains a list with the same number of entries. The number was given in the MQOD. The MQOR entries have fields for destination queue name and queue manager name. The MQRR entries have fields for Completion Code and Reason Code.

Figure 7 shows how you can open a distribution list in COBOL.

Figure 7. Opening a distribution list in COBOL. The MQOD uses offsets in COBOL.

The diagram shows an MQOD (Object Descriptor) data structure. The version number is identified as 2. The structure contains two offsets that identify where in the MQOD the list of MQOR (Object Record) and MQRR (Response Record) values are found. The MQOR entries have fields for destination queue name and queue manager name. The MQRR entries have fields for Completion Code and Reason Code.

Using the MQOPEN options

The following options can be specified when opening a distribution list:

See Chapter 8, Opening and closing objects for a description of these options.

Putting messages to a distribution list

To put messages to a distribution list, you can use MQPUT or MQPUT1. As input, you must supply:

The output is:

Using the MQPMR structure

This structure is optional and gives destination-specific information for some fields that you may want to identify differently from those already identified in the MQMD. For a description of these fields, see WebSphere MQ Application Programming Reference.

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 8 shows how you can put a message to a distribution list in C.

Figure 8. Putting a message to a distribution list in C. The MQPMO uses pointers to the MQPMR and MQRR structures.

The diagram shows an MQPMO (Put Message Options) data structure. The version number is identified as 2. The structure contains   The number of entries to be found in the dependent MQPMR (Put Message Records) and MQRR (Response Record) structures A pointer to a separate MQPMR structure A pointer to a separate MQRR structure.   These structures are also shown, and each contains a list with the same number of entries. The number was given in the MQPMO. The MQPMR entries have fields such as MsgId or CorrelId; the precise fields in the MQPMR depend upon another field in the MQPMO. The MQRR entries have fields for Completion Code and Reason Code.

Figure 9 shows how you can put a message to a distribution list in COBOL.

Figure 9. Putting a message to a distribution list in COBOL. The MQPMO uses offsets in COBOL.

The diagram shows an MQPMO (Put Message Options) data structure. The version number is identified as 2. The structure contains two offsets that identify where in the MQPMO the list of MQPMR (Put Message Records) and MQRR (Response Record) values are found. The MQPMR entries have fields such as MsgId or CorrelId; the precise fields in the MQPMR depend upon another field in the MQPMO. The MQRR entries have fields for Completion Code and Reason Code.

Using MQPUT1

If you are using MQPUT1, consider the following:

  1. The values of the ResponseRecOffset and ResponseRecPtr fields must be null or zero.
  2. The Response Records, if required, must be addressed from the MQOD.


© IBM Corporation 1993, 2002. All Rights Reserved