The Coordinated Request Reply Global Cache sample contains the Coordinated Request Global Cache application and the Coordinated Request Reply Backend application. Both applications have a library reference to Coordinated Request Reply library.
The Coordinated Request Reply Global Cache sample demonstrates the use of a global cache to store information for use by two message flows, a request flow and a reply flow which are running in the Coordinated Request Reply Global Cache application. A BackendReplyApp message flow running in the Coordinated Request Reply Backend application simulates an established application in this sample. The following sections describe the details of the message flows and the processing that they do.
The Request message flow does the following processing:
The flow completes the following actions first:
The flow completes the following action next:
The Request message flow contains the following nodes:
The GetRequestMsg MQInput node reads the XML message. The incoming message is in a self-defining XML format so that you do not have to specify a message set or format for it to be parsed successfully.
The UpdateCacheAtFlowEnd FlowOrder node controls the order of processing.
First, the TransformXMLtoMRM_Sub subflow copies the message headers from the input message to the output message tree, and converts the input message from XML format to CWF by setting the message set, type, and format for the output message.
The SetReplyTo Compute node completes the following actions:
The OutputRequestMsg MQReply node writes the WebSphere MQ output message.
Next, the StoreOriginalMQMD Java Compute node saves the MQMD in the global cache, preserving the ReplyToQ and ReplyToQMgr for use by the reply flow. The MsgId is used as a key to store the data in the global cache for later retrieval. The data is put in the cache only after the main message flow has completed processing successfully.
The Backend Reply message flow completes the following processing:
The Backend Reply message flow contains the following nodes:
The GetRequestMsg MQInput node reads the CWF message. The message set, format, and domain that are required to parse the incoming message are specified on the MQInput node.
The Modify_CompletionTime Compute node completes the following actions:
The PutReplyMsg MQReply node writes the WebSphere MQ output message, copying the MsgId from the request message to the CorrelId field in the reply.
The reply message flow completes the following processing:
The Reply message flow contains the following nodes:
The GetBackendReply MQInput node reads the CWF message. The message set, format, and domain that are required to parse the incoming message are specified on the MQInput node.
The TransformMRMtoXML_Sub subflow copies the message headers from the input message to the output message tree and converts the input message from CWF format to XML.
The RestoreOriginalMQMD JavaCompute node retrieves the original request message MQMD, containing the ReplyToQ and ReplyToQMgr values, from the global cache. The node uses the CorrelId (containing the original request message MsgId) as a key. The existing MQMD in the message is replaced by this original request MQMD.
The PutOriginalReply MQReply node writes the WebSphere MQ output message.
The RemoveMQMDFromCache removes the MQMD data from the global cache message. The cache is cleared only after the main message flow has completed processing successfully.
The test message that is used in the Coordinated Request Reply with Global Cache sample is a simple XML message that contains invoice details for a customer. This sample converts the XML message into the CWF format. The CompletionTime field value is the only value that is changed by the sample. The following example shows the message:
<SaleEnvelope>
<Header>
<SaleListCount>1</SaleListCount>
</Header>
<SaleList>
<Invoice>
<Initial>K</Initial>
<Initial>A</Initial>
<Surname>Braithwaite</Surname>
<Item>
<Code>00</Code>
<Code>01</Code>
<Code>02</Code>
<Description>Twister</Description>
<Category>Games</Category>
<Price>30</Price>
<Quantity>01</Quantity>
</Item>
<Item>
<Code>02</Code>
<Code>03</Code>
<Code>01</Code>
<Description>The Times Newspaper</Description>
<Category>Books and Media</Category>
<Price>20</Price>
<Quantity>01</Quantity>
</Item>
<Balance>50</Balance>
<Currency>Sterling</Currency>
</Invoice>
<Invoice>
<Initial>T</Initial>
<Initial>J</Initial>
<Surname>Dunnwin</Surname>
<Item>
<Code>04</Code>
<Code>05</Code>
<Code>01</Code>
<Description>The Origin of Species</Description>
<Category>Books and Media</Category>
<Price>22</Price>
<Quantity>02</Quantity>
</Item>
<Item>
<Code>06</Code>
<Code>07</Code>
<Code>01</Code>
<Description>Microscope</Description>
<Category>Miscellaneous</Category>
<Price>36</Price>
<Quantity>01</Quantity>
</Item>
<Balance>80</Balance>
<Currency>Euros</Currency>
</Invoice>
</SaleList>
<Trailer>
<CompletionTime>12.00.00</CompletionTime>
</Trailer>
</SaleEnvelope>