Grouping logical messages

 

There are two main reasons for using logical messages in a group:

In either case, retrieve the entire group with the same getting application instance.

For example, assume that the group consists of four logical messages. The putting application looks like this:

   PMO.Options = MQPMO_LOGICAL_ORDER | MQPMO_SYNCPOINT

   MQPUT MD.MsgFlags = MQMF_MSG_IN_GROUP
   MQPUT MD.MsgFlags = MQMF_MSG_IN_GROUP
   MQPUT MD.MsgFlags = MQMF_MSG_IN_GROUP
   MQPUT MD.MsgFlags = MQMF_LAST_MSG_IN_GROUP

   MQCMIT

The getting application chooses not to start processing any group until all the messages within it have arrived. specify MQGMO_ALL_MSGS_AVAILABLE for the first message in the group; the option is ignored for subsequent messages within the group.

Once the first logical message of the group is retrieved, use MQGMO_LOGICAL_ORDER to ensure that the remaining logical messages of the group are retrieved in order.

So, the getting application looks like this:

   /* Wait for the first message in a group, or a message not in a group */
   GMO.Options = MQGMO_SYNCPOINT | MQGMO_WAIT
               | MQGMO_ALL_MSGS_AVAILABLE | MQGMO_LOGICAL_ORDER
   do while ( GroupStatus == MQGS_MSG_IN_GROUP )
      MQGET
      /* Process each remaining message in the group */
      ...

   MQCMIT

For further examples of grouping messages, see Application segmentation of logical messages and Putting and getting a group that spans units of work.

 

Parent topic:

Logical and physical ordering


fg12630_