Using a local file as input for your message flow

Learn how to use the FileInput node to read a file on your local file system and then propagate messages that are based on the contents of that file.

Before you begin

This example shows how one combination of values in the Record detection, Delimiter, and Delimiter type properties can be used to extract messages from a file. The example describes the FileInput node of a message flow and assumes that the rest of the flow has already been developed. It is also assumed that a Windows system is being used. To complete this example task, you must first have added a FileInput node to a message flow. You also need the following resources:
  • An input file. To follow this example scenario, create an input file called test_input1.xml with the following content:
    <Message>test1</Message>
    <Message>testtwo</Message>
    <Message>testthree</Message>
    Each line ends with a line terminator; on a Windows system, this comprises carriage return and line feed characters (X'0D0A'). Put this file into directory C:\FileInput\TestDir.
  • A message set. This example uses a message set called xml1 which uses the XMLNSC parser. Message set xml1 models messages of the following form:
    <Message>...</Message>
For more information about configuring the FileInput node, see Configuring the FileInput node.

Complete the following steps:

Procedure

  1. Set the required node properties on the FileInput node.
    The following table summarizes the FileInput node properties that you should set, which tab they appear on and the value that you should set in order to follow this example:
    Tab Property Value
    Basic Input directory C:\FileInput\TestDir
    File name or pattern test_input1.xml
    Action on successful processing Move to Archive Subdirectory
    Replace duplicate archive files Selected
    Input Message Parsing Message domain XMLNSC
    Message model xml1
    Polling Polling interval 3
    Retry Action on failing file Add Time Stamp and Move to Backout Subdirectory
    Records and Elements Record detection Delimited
    Delimiter DOS or UNIX Line End
    Delimiter type Postfix
    FTP FTP Not selected
  2. Deploy the message flow to the integration node. See Deploying integration solutions.

Results

The following actions occur when you perform these steps:
  1. The file is processed. In accordance with the values set in the properties on the Records and Elements tab, the FileInput node detects records that are separated by DOS or UNIX end-of-line characters and creates a message for each one that it finds. It propagates three messages to the flow attached to the Out terminal:
    • Message 1:
      <Message>test1</Message>
    • Message 2:
      <Message>testtwo</Message>
    • Message 3:
      <Message>testthree</Message>
  2. If a flow is attached to the End of Data terminal, the End of Data message is propagated after the last record in the file has been processed.
  3. When processing is complete, the file test_input1.xml is moved to the mqsiarchive subdirectory, C:\FileInput\TestDir\mqsiarchive\test_input1.xml. If a file called test_input1.xml already exists in the mqsiarchive subdirectory, it is overwritten.
  4. If the message flow fails, retry processing is attempted according to the values set in the properties of the FileInput node. In this example task, a time stamp is added to the file name and the file is moved to the mqsibackout directory. Here is an example of the path to such a file: C:\FileInput\TestDir\mqsibackout\20070928_150234_171021_test_input1.xml.

What to do next

To see the effects of specifying other combinations of values in the Record detection, Delimiter, and Delimiter type properties of the FileInput node, see Controlling how files are separated into records.

To extend this example to process files from within subdirectories, put the input file in a subdirectory of Input directory, and select the property Include local subdirectories.