Routing or enriching a message based on the contents of a file
The FileRead node can route or enrich messages based on the contents of the file.
When developing the message flow you can specify the name and location of the file to be read. You can override these values at run time based on the contents of a message.
The node complements the existing FileInput and FileOutput nodes. The FileRead node reads a file in the middle of a message flow.
Using the node to route messages
A message is routed by using the contents of a file colocated with IBM® App Connect Enterprise or on a network file system. The message from the source system is routed to a target system by using an external routing file. No response is expected.
The
basic flow of events is as follows:
- IBM App Connect Enterprise receives a message through an input node.
- The IBM App Connect Enterprise message flow interrogates the contents of a message to identify routing key information.
- If the file consists of more than one record, you need to determine:
- Where the first record starts. Unless you specify an offset byte, the node starts reading the file at the first byte.
- How each record ends (fixed-sized, delimited, or parsed.)
- Which record to propagate. You can use any combination of information
from the input message and the file in deciding this. All records
from the specified start point are read until a record is found that
matches the record selection expression, this record is then propagated.
Examples include:
- The third record, as identified by the local environment field
$OutputLocalEnvironment/File/Read/RecordNumber=3
. In this example, the first record is fully read and the expression evaluates to false. The second record is then fully read and the expression evaluates to false. When the third record is fully read, the expression evaluates to true and the record is propagated. No further records are read. - A key field in the input message matches a key field in the file
$InputRoot/XMLNSC/FromMQInputMessage/Record1 = $ResultRoot/XMLNSC/FromFile/Record5
. In this example, records are read from the file until the value of the Record5 element of the record matches the value of the Record1 element of the incoming message. The location of the record in the file determines how many records the node must read before successfully matching the record selection expression.
- The third record, as identified by the local environment field
- Within the message flow you can implement a local cache of records to reduce the performance cost of reading multiple static records.
- You can choose to take information from the file, and copy it to the outgoing message. The copy can be a subset of the data, and can be copied to any location in the message or the local environment. For more information, see Combining a result message with an input message when fetching data from external systems.
- A target application receives the routed message.