2007年12月9日 星期日

[MQueue] Message Group and Message Segmentation

.
. IBM WebSphere MQ v6.0
. Chapter 3.1 - IBM WebSphere Message Group and Message Segmentation
.

=== 關於 Message and Correlation Identifiers ===
Two fields in the Message Descriptor :
1. MsgID (message identifier ) :
 If an application specifies MQMI_NONE on an MQPUT call, the Queue Manager
 generates a unique message identifier.

2. CorrelID (correlation identifier) :
 In a reply or report message, it is normally copies from the MsgID of the original message.

※ Both fields are treated as bit strings by the Queue Manager.


=== 關於 Retrieving Messages ===
1. With selection criteria :
 - Set MsgID and/or CorrelID prior to an MQGET call
 - Also ensure that MatchOptions in get message options is set to
  MQMO_MATCH_MSG_ID + MQMO_MATCH_CORREL_ID

2. Without selection criteria :
 - Reset MsgID and CorrelID to MQMI_NONE and MQCI_NONE respectively
  before each MQGET call
 - Or, set MatchOptions in get message options to MQMO_NONE

3. On return from an MQGET call, MsgID and CorrelID are set to the values
  for the message retrieved.


=== Order of Retrieving Messages 取出訊息順序 ===
1. Messages on a Queue can be retrieved by an application in the same order
  they were put by another application, provided :
 - The messages all have the same priority.
 - The messages were all put within the same unit of work, or all put outside of a unit of work.
 - No other application is getting messages from the Queue.
 - The Queue is Local to the putting application.
 - But they may be interspersed with messages put by other applications.

2. If the Queue is not Local to the putting application, the order of retrieval is still
  preserved provided :
 - The first three conditions above still apply.
 - Only a single path is configured for the messages.
 - No message is put on a Dead Letter Queue
 - No nonpersistent messages are transmitted over a fast message channel.


=== 關於 Message Group (Guaranteed 機制) ===
[ Message Group ] <= (Logical message 1) + (Logical message 2) + (Logical message 3)

※ A Message Group : Consists of one or more logical messages.

※ A Logical message is :
 - A physical message (unless it is split into segments).
 - Identified by the GroupID and MsgSeqNumber fields in the message desccriptor.

說明:
1. All logical messages belonging to the same group have the same value for the GroupID field.

2. The MsgSeqNumber field has the value 1 for the first logical message, 2 for the second,
 and so on.There is, therefore, an implied ordering to the logical messages within a group.

3. A physical message which does not belong to any group has the value MQGI_NONE in
 the GroupID field, and the value 1 in the MsgSeqNumber field.


=== 關於Message Group 2 個主要用途 ===
1. To ensure ordering on retrieval in circumstances where this is not already guaranteed.
 - An application is able to put a sequence of messages constituting a Message Group on a Queue by specifying the put message option MQPMO_LOGICAL_ORDER. The Queue Manager generates a unique group identifier (GroupID) and assigns a message sequence number (MsgSeqNumber) to each message as it it put on the Queue.
 - Another application is then able to get the messages constituting the group from the Queue, in the same order they were put, by specifying the get message option MQGMO_LOGICAL_ORDER.

2. To allow an application to group together related messages.
 - This may be useful, for example, if it is important for a group of related messages to be processed by the same server instance, or by a particular server instance. By setting the value MQMO_MATCH_GROUP_ID in the MatchOptions filed in get message options, an application can retrieve only those messages with a specified group Identifier.

※ Needed : (Version 5 and 6 Queue Managers only)
 - To ensure ordering on retrieval (Where it is not already guraranteed).
 - To allow an application to group together related messages.


=== 關於 Message Segmentation ===
為了解決以前的程式,Message buffer固定且小的問題。
※ A segment is :
 - A physical message.
 - Identified by the GroupID, MsgSeqNumber, Offset fields in the message descriptor.

※ Segmentation is needed when a message is too large for an application, a Queue, or a Queue Manager.

※ A message can be segmented and reassembled :
 - By the Queue Manager.
 - By an application.

1. To ask the Queue Manager to segment a message if necessary, the putting application simply sets the value MQMF_SEQMENTATION_ALLOWED in the MsgFlags field of the message descriptor and issues one MQPUT call.

Similarly, the getting application simply specifies the get message option MQGMO_COMPLETE_MSG in order to request the Queue Manager only to return a complete logical message on an MQGET call. And if the logical message is segmented, the Queue Manager reassembles it before returning it to the application.

2. If a message is too large for an application to handle in a songle buffer, the application may perform the segmentation itself by issuing an MQPUT call for each segment. Similarly, an application may issue an MQGET call for each segment of a logical message.

沒有留言:

張貼留言