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:
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.<Message>test1</Message> <Message>testtwo</Message> <Message>testthree</Message>
- A message set. This example uses a message set called
xml1
which uses the XMLNSC parser. Message setxml1
models messages of the following form:<Message>...</Message>
Complete the following steps:
Procedure
Results
- 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>
- Message 1:
- 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.
- 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.
- 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.