Description:

Routes FlowFiles based on their Attributes using the Attribute Expression Language

Tags:

attributes, routing, Attribute Expression Language, regexp, regex, Regular Expression, Expression Language

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
Routing Strategy Route to Property name * Route to Property name
* Route to 'matched' if all match
* Route to 'matched' if any matches
Specifies how to determine which relationship to use when evaluating the Expression Language

Dynamic Properties:

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

Name Value Description
Relationship Name Attribute Expression Language Routes FlowFiles whose attributes match the Attribute Expression Language specified in the Dynamic Property Value to the Relationship specified in the Dynamic Property Key
Supports Expression Language: true

Relationships:

Name Description
unmatched FlowFiles that do not match any user-define expression will be routed here

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 Attribute Expression Language

Reads Attributes:

None specified.

Writes Attributes:

None specified.

Usage Example

This processor routes FlowFiles based on their attributes using the Expression Language Guide. Users add properties with valid Expression Language Guide Expressions as the values. Each Expression must return a value of type Boolean (true or false).

Example: The goal is to route all files with filenames that start with ABC down a certain path. Add a property with the following name and value:

  • property name: ABC

  • property value: ${filename:startsWith(‘ABC’)}

In this example, all files with filenames that start with ABC will follow the ABC relationship.

How to configure?:

Step 1: Drag and drop the RouteOnAttribute processor to canvas.

Step 2: Double click the processor to configure, the configuration dialog will be opened as follows,

properties

Step 3: Check the usage of processor property and update those values.

Properties and usage:

Routing Strategy: This property is used to specify which relationship should be used based on the expressions given.

Route to Property name: Here the property name will act as relationship.If the flow file attribute satisfy the expression given in each property, a copy of the flow file will be routed to the corresponding relationship.

Route to ‘matched’ if all match: Flow files will be transferred to matched relationship if expression given in all the properties are satisfied.

Route to ‘matched’ if any matches: Flow files will be transferred to matched relationship if expression given in any one of the property is satisfied.

For example, add the following new properties in RouteOnAttribute processor to get the files less than 1024 KB and the file name contains input text. Here, routing strategy as Route to matched if all match is used to get files which satisfies both the conditions in matched relationship.

If you change routing strategy to Route to Property name, then the files whose size is less than 1024 KB will be transferred to file size relationship and files whose name contains input will be transferred to filename relationship.

If you need files less than 1024 KB or file name which contains input, then you can use Route to ‘matched’ if any matches strategy.

sample