Description and usage of RouteOnContent processor:

Applies Regular Expressions to the content of a FlowFile and routes a copy of the FlowFile to each destination whose Regular Expression matches. Regular Expressions are added as User-Defined Properties where the name of the property is the name of the relationship and the value is a Regular Expression to match against the FlowFile content. User-Defined properties do support the Attribute Expression Language, but the results are interpreted as literal values, not Regular Expressions

Tags:

route, content, regex, regular expression, regexp

Properties:

In the list below, the names of required properties appear in bold. Any other properties (not in bold) are considered optional. The table also indicates any default values.

Name Default Value Allowable Values Description
Match Requirement content must match exactly * content must match exactly
* content must contain match
Specifies whether the entire content of the file must match the regular expression exactly, or if any part of the file (up to Content Buffer Size) can contain the regular expression in order to be considered a match
Character Set UTF-8 The Character Set in which the file is encoded
Content Buffer Size 1 MB Specifies the maximum amount of data to buffer in order to apply the regular expressions. If the size of the FlowFile exceeds this value, any amount of this value will be ignored

Dynamic Properties:

Dynamic Properties allow the user to specify both the name and value of a property.

Name Value Description
Relationship Name A Regular Expression Routes FlowFiles whose content matches the regular expressoin defined by Dynamic Property's value to the Relationship defined by the Dynamic Property's key
Supports Expression Language: true

Relationships:

Name Description
unmatched FlowFiles that do not match any of the user-supplied regular expressions will be routed to this relationship

Dynamic Relationships:

A Dynamic Relationship may be created based on how the user configures the Processor.

Name Description
Name from Dynamic Property FlowFiles that match the Dynamic Property's Regular Expression

Reads Attributes:

None specified.

Writes Attributes:

None specified.

How to configure?

Sample for RouteOnContent processor:

This sample explains how to route the flow files based on the file content and store it in the local file system.

Overview:

sample

Step 1: Get the log file

Drag and drop the TailFile processor to get the “dataintegration-bootstrap.log” file content and configure it as follows.

sample

Step 2: Splitting the file

Drag and drop the SplitText processor to split the text in a file line by line and configure it as follows.

sample

Step 3: Route the flow files

Drag and drop the RouteOnContent processor to route the flow files that match the added properties.

Properties and usage:

Match Requirement: A matching strategy for the RouteOnContent processor with “Content must contain match” and “Content must match exactly” options.

Content must contain match: Property to check the added regular expression, to match with the flow file content. The flow files will be routed to the corresponding relationship if the content of the flow file contains the added property.

Content must match exactly: Property to check the added regular expression, to match exactly with the whole flow file content. The flow files will be routed to the corresponding relationship if the content of the flow file matches the added property.

Character Set: Specifies the character set in which the incoming file is encoded.

Content Buffer Size: Specifies the buffer limit to apply the regular expressions.

Add the following properties and configure it as follows:

Info: The flow file contains the content “INFO” will be routed to the corresponding relationship.

Warn: The flow file contains the content “WARN” will be routed to the corresponding relationship.

sample

Step 4: Update the file names

Drag and drop the UpdateAttribute processor to update the file name of flow files as follows.

Info_UpdateAttribute configuration:

sample

Warn_UpdateAttribute configuration:

sample

Step 5: Store the file

Drag and drop the PutFile processor to store the output files in a local file system and configure it as follows.

sample

info file.txt:

sample

warn file.txt:

sample