An OLTP message-driven bean receives the inbound message as the inMsg
parameter of the onMessage()
method. The received object is an OltpMessage
object. From the OltpMessage
object you can retrieve an OltpMessageContext
object which in turn contains attributes of the received message and serves dialog OLTPmessage-driven beans as a factory for creating a response message:
- Access to the message context:
OltpMessageContext oltpMsgCtx = inMsg.getMessageContext();
Access the message content:
TheOltpMessage
object allows access to the message content which may be processed in the form ofOltpMessageRecord
orOltpMessagePart
objects.In the case of
OltpMessagePart
objects you specify:String inMsgTxt = ""; if (inMsg.countMessageParts() > 0) { OltpMessagePart inMsgPart; Iterator it<OltpMessagePart> = inMsg.getMessageParts(); for ( ; it.hasNext(); ) { inMsgPart = it.next(); inMsgTxt += inMsgPart.getText(); } }
In the case of
OltpMessageRecord
objects you specifyif (inMsg.countMessageRecords() > 0) { OltpMessageRecord inMsgRec; Iterator it<OltpMessageRecord> = inMsg.getMessageRecords(); for ( ; it.hasNext(); ) { inMsgRec = it.next(); inMsgTxt += inMsgRec.getText(); } }
Creating a reply message (only in the case of OLTP message-driven beans for dialog communication):
An OLTP message-driven bean for dialog communication uses the
OltpMessageContext
interface to create anOltpMessage
object for the reply message:OltpMessage outMsg = oltpMsgCtx.createMessage();
The
OltpMessage
object needs to be populated with message content (only in the case of OLTP message-driven beans for dialog communication). You can do this in different ways usingOltpMessageRecord
and/orOltpMessagePart
objects.You should construct the response message using
OltpMessagePart
objects if the message recipient is to be sent a response structured in message segments. If the recipient is an UTM application then it reads each message segment transferred with anOltpMessagePart
object by means of a separate MGET call.If it is not important for the response message to be structured in message segments then it is more advantageous to use
OltpMessageRecord
objects.
You will find a code sample of an "OLTP message-driven beans for dialog communication" in OLTP message-driven beans and a code sample of an "OLTP message-driven beans for asynchronous communication " in OLTP message-driven beans .