Professional Documents
Culture Documents
Introduction To The Message Queue Interface (MQI)
Introduction To The Message Queue Interface (MQI)
Introduction To The Message Queue Interface (MQI)
Interface (MQI)
• Equivalent in C
MQPUT1 (Hconn, &ObjDesc, &MsgDesc, &PutMsgOpts,
BufferLength, Buffer, &CompCode, &Reason);
• Equivalent in COBOL
CALL "MQPUT1" USING HCONN, OBJDESC, MSGDESC, PUTMSGOPTS,
BUFFERLENGTH, BUFFER, COMPCODE, REASON.
• Close object
MQCLOSE (Hconn, Hobj, Options, CompCode, Reason)
or
MYQUEUE
or
MYQUEUE.*
*
• MsgDesc • BufferLength
– Message descriptor – Length of the message in buffer
– Input fields set by the application
– Output fields set by the queue manager • Buffer
– Message data
• PutMsgOpts
– Message options
Examples:
MQPMO_SYNCPOINT
MQPMO_FAIL_IF_QUIESCING
• GetMsgOpts • BufferLength
– Message options – Length of the buffer area
Examples:
MQGMO_ACCEPT_TRUNCATED_MSG • Buffer
MQGMO_BROWSE – Area to contain the message data
MQGMO_CONVERT
MQGMO_FAIL_IF_QUIESCING
MQGMO_SYNCPOINT
• DataLength
MQGMO_WAIT – Length of the message returned
• WaitInterval
– Maximum time the application waits
– Application can specify an unlimited
wait.
MQGET MSGID=MQMI_NONE
CORRELID=3
MQGET MSGID=4
CORRELID=MQCI_NONE
MQGET MSGID=4
CORRELID=2
ID=
1 D=2 ID=
3 D=1 D=2 D=1
ELI ELI ELI ELI
RREL O RR RREL O RR RR RR
CO 3 C CO = 4 C 4 CO 5 CO
3 = 3 = =
GID
= GID GID
= GID GID GID
MS MS MS MS MS MS
Segment 1 Segment 2
• A segment is:
– A physical message
– Identified by the GroupId, MsgSeqNumber, and Offset fields in the
message descriptor
• Segmentation is needed when a message is too large for an
application, a queue, or queue manager
• A message can be segmented and reassembled:
– By the queue manager
– By an application
© Copyright IBM Corporation 2008
Distribution list
CALL MQOPEN . . . Version 6 or higher queue
managers only
CALL MQPUT . . .
DALLAS
HURSLEY
?
PARIS
?
Distribution list
ObjectName ObjectQMgrName DALLAS SEATTLE
MAIL_IN_HURSLEY
MAIL_IN_PARIS
MAIL_IN_DALLAS
MAIL_IN_SEATTLE
MAIL_IN
MAIL_IN
© Copyright IBM Corporation 2008
Message properties
• Arbitrary values associated with the
message but not part of the body
– Like a user-extendable MQMD
– Already part of JMS
MQMD
• New verbs MQSETMP and
MQINQMP
– Properties can be integers, strings,
Booleans, and so on
BODY Props
• Easier to use than RFH2 folders
– Receiving applications do not see them
unless they want Color=blue
– No need to parse and skip over Type=mobile
message headers
MQCRTMH(hConn,
MQCRTMH(hConn, &CrtMsgHOpts,
&CrtMsgHOpts, &hRequestMsg,
&hRequestMsg, &CC,
&CC, &RC);
&RC);
GetMsgOpts.MsgHandle = hRequestMsg;
GetMsgOpts.MsgHandle = hRequestMsg;
MQGET(hConn,
MQGET(hConn, hObj,
hObj, &MD,
&MD, &PutMsgOpts,
&PutMsgOpts, DataLen,
DataLen, &Buffer,
&Buffer,
&CC, &RC);
&CC, &RC);
//
// 2.
2. Forward
Forward request
request unchanged
unchanged to
to server
server application
application
//
// named in message
named in message
PutMsgOpts.Action
PutMsgOpts.Action == MQPACT_FORWARD;
MQPACT_FORWARD;
PutMsgOpts.OriginalHandle
PutMsgOpts.OriginalHandle == hRequestMsg;
hRequestMsg;
MQPUT(hConn,
MQPUT(hConn, hServerObj, &MD, &PutMsgOpts,
hServerObj, &MD, &PutMsgOpts, DataLen,
DataLen,
&Buffer, &CC, &RC);
&Buffer, &CC, &RC);
Name.VSPtr
Name.VSPtr == “RequestStatus”;
“RequestStatus”;
Name.VSLength
Name.VSLength == MQVS_NULL_TERMINATED;
MQVS_NULL_TERMINATED;
MQSETMP(hConn,
MQSETMP(hConn, hRequestMsg,
hRequestMsg, &SetPropOpts,
&SetPropOpts, &Name,
&Name,
&PropDesc,
&PropDesc, MQTYPE_STRING, “REQUEST_RECEIVED”, 16,
MQTYPE_STRING, “REQUEST_RECEIVED”, 16, &CC,
&CC,
&RC);
&RC);
PutMsgOpts.Action
PutMsgOpts.Action == MQPACT_REPLY;
MQPACT_REPLY;
PutMsgOpts.OriginalMsgHandle
PutMsgOpts.OriginalMsgHandle == hRequestMsg;
hRequestMsg;
MQPUT(hConn,
MQPUT(hConn, hReplyObj,
hReplyObj, &MD,
&MD, &PutMsgOpts,
&PutMsgOpts, DataLen,
DataLen,
&Buffer, &CC, &RC);
&Buffer, &CC, &RC);
• Example:
“JMSType = ‘car’ AND color = ‘blue’ AND weight > 2500”