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
- An input file. To follow this example scenario, create an input
file called test_input1.xml with the following
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
xml1which uses the XMLNSC parser. Message set
xml1models messages of the following form:
Complete the following steps:
- 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
- Deploy the message flow to the integration node. See Deploying integration solutions.
- 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 2:
- Message 3:
- 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.