Combining a WebSphere® MQ message with an XML file using the contents of the message to identify which file to use

Combine an incoming message with the contents of an XML file, using fields in the message to determine which file to use.

Before you begin

Put a file on the file system that is local to the integration node, for the FileRead node to read. Here is an example of the file contents:

<Data>Purchase details</Data>

In this example, the contents of the data in the data tag are inserted into the incoming message. Any valid XML structures can be added to this section.

Make a note of the path to the file. For example: c:\temp\FileRead\task3.xml or /tmp/FileRead/task3.

Create the following queues on the integration node queue manager:

  • FILEREAD.TASK3.IN1
  • FILEREAD.TASK3.OUT1

Detailed information about configuring the node is given on the property panels for the node, in the IBM® Integration Toolkit.

Procedure

  1. Create a message flow that contains an MQInput node, a FileRead node, and an MQOutput node.
  2. Wire the terminals as follows:
    1. Wire the Out terminal of the MQInput node to the In terminal of the FileRead node.
    2. Wire the Out terminal of the FileRead to the In terminal of the MQOutput node.
  3. Configure the MQInput node:
    1. On the Basic panel, set the Queue name to FILEREAD.TASK3.IN1
    2. On the Input Message Parsing panel set the domain to XMLNSC.
  4. Configure the FileRead node.
    1. On the Basic panel, set the directory and file name to refer to the XML file. For example: c:\temp\FileRead and task3.xml or /tmp/FileRead and task3.
    2. Configure the Result panel:
      1. Set the Result data location to $ResultRoot/XMLNSC/Data
      2. Set the Output data location to $InputRoot/XMLNSC/Data
    3. Configure the Input Message Parsing panel:
      1. Set the Domain to XMLNSC
  5. Configure the MQOutput node:
    1. On the Basic panel, set the Queue name to FILEREAD.TASK3.OUT1
  6. Deploy the message set and message flow.
  7. Change the Directory and Name fields to the correct location of the file, and then put the following XML message onto queue FILEREAD.TASK2.IN1:
    <Invoice>
      <Directory>c:\temp\FileRead</Directory>
      <Name>task2.xml</Name>
      <Data/>
    </Invoice>
    

Results

The integration node routes the message to the queue FILEREAD.TASK3.OUT1 and inserts data from the file into the Data field of the output message:

<Invoice>
  <Directory>c:\temp\FileRead</Directory>
  <Name>task2.xml</Name>
  <Data>Purchase details</Data>
</Invoice>