The Coordinated Request Reply sample is a message flow sample application based on the scenario of a contemporary and established application communicating through the use of WebSphere MQ messages in a request/reply processing pattern. The contemporary application uses self-defining XML messages and issues a request message. The established application uses Custom Wire Format (CWF) messages. It receives a request message, processes it and delivers a reply message. For the applications to successfully communicate, the message formats must be transformed for both the request and reply messages.
The sample demonstrates how conversion can be achieved between self-defining XML messages and CWF messages. In addition the sample demonstrates how it is possible to store information in one message flow and retrieve it in another. In the sample there is a need to preserve the ReplyToQ and ReplyToQMgr from the initial request message for use when the corresponding reply message is received. In the scenario a WebSphere MQ message is used to store the details.
The processing in the sample consists of three message flows and one message set. The message flows are:
This reads a request message from an application that is able to write the test message for this sample, transforms the payload from XML to CWF, and writes an output message containing a CWF format payload. This message is read and processed by the Backend Reply message flow, which simulates an established application.
This simulates an established application that receives a WebSphere MQ message containing a payload in CWF format, performs some processing on the contents, and writes a reply WebSphere MQ message containing a payload in CWF format.
This reads the reply message from the Backend Reply message flow, transforms the payload from CWF to XML, and writes an output message containing an XML format payload. This message is read and processed by the originating application.
The message set Sample MSET with message definition SaleListMessage is used in the conversion of the message from XML format to CWF on the request section of the processing, and in the conversion from CWF to XML on the reply section of the processing.
The details of the message flows and the processing they perform is described below.
The request message flow performs the following processing:
The Request message flow consists of the following nodes:
The MQInput node GetRequestMsg reads the XML message. As the incoming message is in a self-defining XML format there is no need to specify a message set or format for it to be parsed successfully.
The subflow StoreOriginalMQMD_Sub encapsulates the storage of the ReplyToQ and ReplyToQMgr values in a WebSphere MQ message. This encapsulation is done for two reasons: Firstly to allow the processing logic to be easily reused in other message flows and secondly to allow alternative implementations to be substituted. For example an alternative implementation that uses a database node could be created.
The Compute node TransformAndSetReplyTo performs the following actions:
The MQReply node OutputRequestMsg writes the WebSphere MQ output message.
The backend reply message flows performs the following processing:
The Backend Reply message flow consists of the following nodes:
The MQInput node GetRequestMsg reads the CWF message. The message set, format, and domain that are needed to parse the incoming message are specified on the MQInput node.
The compute node Backend_Computation performs the following actions:
The MQReply node PutReplyMsg writes the WebSphere MQ output message.
The reply message flow performs the following processing:
The Reply message flow consists of the following nodes:
The MQInput node GetBackendReply reads the CWF message. The message set, format, and domain that are needed to parse the incoming message are specified on the MQInput node.
The compute node MapToRequestor performs the following actions:
The subflow RestoreOriginalMQMD_Sub encapsulates the retrieval of the ReplyToQ and ReplyToQMgr values. It reads the WebSphere MQ message containing the values of ReplyToQ and ReplyToQMgr that were specified in the original request message and copies them into the reply message. It does the read by using the MQGet node. The MQGet node is configured to select the corresponding message by CorrelId and to copy the original request MQMD into the MQMD of the message being processed. This is done to direct the reply message from the established application to the correct requester application. The MQGet node also retrieves the payload of the WebSphere MQ message which was used to store the original values of ReplyToQ and ReplyToQMgr.
The MQReply node PutOriginalReply writes the WebSphere MQ output message.
The test message used in the coordinated request reply sample is a simple XML message that contains invoice details for a customer. During the execution of the sample this XML message is converted into the CWF format. The CompletionTime field value is the only value to change during the execution of the sample. The message is shown below.
<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>00.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>00.20</Price>
<Quantity>01</Quantity>
</Item>
<Balance>00.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.34</Price>
<Quantity>02</Quantity>
</Item>
<Item>
<Code>06</Code>
<Code>07</Code>
<Code>01</Code>
<Description>Microscope</Description>
<Category>Miscellaneous</Category>
<Price>36.20</Price>
<Quantity>01</Quantity>
</Item>
<Balance>81.84</Balance>
<Currency>Euros</Currency>
</Invoice>
</SaleList>
<Trailer>
<CompletionTime>12.00.00</CompletionTime>
</Trailer>
</SaleEnvelope>