Use the AbtMQMessage class to specify the message options. Then you can get the message from the queue using a variety of get... methods.
This example uses the msgId: method of AbtMQMessage to specify the message ID of the message being retrieved. Any messages that do not match the specified message ID will be left on the queue.
| aModelMessage aQueue rc |
"Sample App 1: getting two messages with the same msg ids"
CICSTTY cr; show: 'Get messages with 'Msg Duplicate''
message ID from the queue.'.
"Define the message"
aModelMessage := AbtMQMessage new msgId: 'Msg Duplicate'; length: 100.
rc := nil.
[rc isAbtError not]
whileTrue: [
"Get the message from the queue and verify the call"
(rc := aQueue getMessageWithModelMessage: aModelMessage)
isAbtError
ifTrue: [rc reason = MqrcNoMsgAvailable " 2033 "
ifTrue: [CICSTTY cr;
show: 'The NoMsgAvailable reason code
is expected for Msg Duplicate.'.]
ifFalse: [CICSTTY cr;
show: 'No Msg returned, reason code: ',
(rc codesAsString)]]
ifFalse: [CICSTTY cr;
show: 'Message ID is: ', (rc msgId);
show: ', Data is: ', (rc contentsAsString)]
].
Sample Application 2 uses the AbtMQMessage class to specify the message options:
| rc anMQConnection |
"Sample App 2: simple get using the connection"
(rc := aQueueConnection get) isAbtError
ifTrue: [rc reason = MqrcNoMsgAvailable " 2033 "
ifTrue: [CICSTTY cr;
show: 'The NoMsgAvailable reason code
is expected.'.]
ifFalse: [CICSTTY cr;
show: 'No Msg returned, reason code: ',
(rc codesAsString)]]
"Message received: show some of the values"
ifFalse: [CICSTTY
cr; show: 'Message ID is: ', (rc msgId);
cr; show: 'Data is: ', (rc contentsAsString);
cr; show: ' putApplName: ', (rc putApplicationName);
cr; show: ' putApplType: ',
(rc putApplicationType printString).].