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:
TheOltpMessageobject allows access to the message content which may be processed in the form ofOltpMessageRecordorOltpMessagePartobjects.In the case of
OltpMessagePartobjects 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
OltpMessageRecordobjects 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
OltpMessageContextinterface to create anOltpMessageobject for the reply message:OltpMessage outMsg = oltpMsgCtx.createMessage();The
OltpMessageobject 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 usingOltpMessageRecordand/orOltpMessagePartobjects.You should construct the response message using
OltpMessagePartobjects 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 anOltpMessagePartobject 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
OltpMessageRecordobjects.
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.