About the Coordinated Request Reply JMS sample

The Coordinated Request Reply JMS Sample contains the Coordinated Request Reply JMS Application. This application has a library reference to the Coordinated Request Reply Library.

The Coordinated Request Reply JMS sample demonstrates how to use the JMSReceive node. The following sections describe the message flows and the processing that they perform.

Request message flow

The request message flow performs the following processing:

  1. Reads a JMS message containing an XML payload
  2. Saves the original ReplyToQ details in a separate JMS message for subsequent retrieval by the Reply message flow
  3. Converts the message into the equivalent CWF format
  4. Creates a JMS message containing the transformed message
  5. Sets the ReplyToQ details to be the input of the Reply message flow
  6. Sends the message to the Backend Reply message flow

The Request message flow contains the following nodes:

The Request message flow contains a JMSInput node, two subflow nodes, a Compute node, and a JMSOutput node.

The GetRequestMsg JMSInput node reads the XML message. The incoming message is in a self-defining XML format so that you are not required to specify a message set or format for it to be parsed successfully.

The StoreOriginalJMSHeader_Sub subflow encapsulates the storage of the ReplyToQ and Correlation ID values in a JMS message. The Message ID is being copied into Correlation ID. This encapsulation is done for two reasons: to allow the processing logic to be easily reused in other message flows, and to allow alternative implementations to be substituted. For example, an alternative implementation that uses a database node can be created.

The TransformXMLtoMRM_Sub subflow copies the message headers from the input message to the output message tree and performs the conversion of the input message from XML format to CWF by setting the message set, type, and format for the output message.

The SetReplyTo_CorrelID Compute node performs the following actions:

  1. Copies the message headers from the input message to the output message tree.
  2. Copies the message body from the input message to the output message tree.
  3. Sets the Correlation ID as Message ID.
  4. Sets the ReplyToQ for the new message to be that of the input queue for the reply message flow.

The OutputRequestMsg JMSOutput node writes the JMS output message.

Backend Reply message flow

The backend reply message flows performs the following processing:

  1. Reads a JMS message.
  2. Adds the time that the message was modified to the payload of the message.
  3. Writes a JMS message.

The Backend Reply message flow contains the following nodes:

The Backend Reply message flow contains a a JMSInput node, Compute node, and a JMSReply node.

The GetRequestMsg JMSInput node reads the CWF message. The message set, format, and domain that are required to parse the incoming message are specified on the JMSInput node.

The Modify_CompletionTime Compute node performs the following actions:

  1. Copies the entire input message to the output message tree
  2. Obtains the current time from WebSphere Message Broker and reformats it
  3. Adds the reformatted time to the output message tree

The PutReplyMsg JMSReply node writes the JMS output message.

Reply message flow

The reply message flow performs the following processing:

  1. Reads a JMS message containing a message in CWF format
  2. Converts the message into the equivalent XML format
  3. Obtains the ReplyToQ details of the original request message by reading the JMS message that was used to store this information in the Request message flow. This action is performed by the JMSReceive node.
  4. Creates a JMS message containing the transformed message and the retrieved ReplyToQ value.

The Reply message flow consists of the following nodes:

The Reply message flow contains a JMSInput node, two subflow nodes, and a JMSReply node.

The GetBackendReply JMSInput node reads the CWF message. The message set, format, and domain that are required to parse the incoming message are specified on the JMSInput 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 RestoreOriginalJMSHeader_sub flow contains the JMSReceive node.

The RestoreOriginalJMSHeader_Sub subflow encapsulates the retrieval of the ReplyToQ and Correlation ID values. It use a JMSReceive node to read the JMS message containing the value of ReplyToQ and Correlation ID that were specified in the original request message and copies them into the reply message. A Compute node is before the JMSReceive node in the flow. In the Compute node the Correlation ID property of the JMSReceive node is overridden in the environment variable by the Correlation ID of reply message. The JMSReceive node is configured to select the corresponding message by its Correlation ID, and to copy the original request JMSHeader into the JMSHeader of the message being processed to direct the reply message from the established application to the correct requester application. The JMSReceive node also retrieves the payload of the JMS message that was used to store the original values of ReplyToQ.

For more information about the JMSReceive node, see JMSReceive node in the WebSphere Message Broker documentation.

The PutOriginalReply JMSReply node writes the JMS output message.

Test message

The test message used in the Coordinated Request Reply 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>

Back to sample home