@EventDriven @SideEffectFree @SupportsBatching @InputRequirement(value=INPUT_REQUIRED) @Tags(value={"attributes","routing","Attribute Expression Language","regexp","regex","Regular Expression","Expression Language"}) @CapabilityDescription(value="Routes FlowFiles based on their Attributes using the Attribute Expression Language") @DynamicProperty(name="Relationship Name", value="Attribute Expression Language", supportsExpressionLanguage=true, description="Routes FlowFiles whose attributes match the Attribute Expression Language specified in the Dynamic Property Value to the Relationship specified in the Dynamic Property Key") @DynamicRelationship(name="Name from Dynamic Property", description="FlowFiles that match the Dynamic Property\'s Attribute Expression Language") @WritesAttributes(value=@WritesAttribute(attribute="RouteOnAttribute.Route",description="The relation to which the FlowFile was routed")) public class RouteOnAttribute extends AbstractProcessor
This processor routes a FlowFile based on its flow file attributes by using the Attribute Expression Language. The Expression Language is used by adding Optional Properties to the processor. The name of the Property indicates the name of the relationship to which a FlowFile will be routed if matched. The value of the Property indicates an Attribute Expression Language Expression that will be used to determine whether or not a given FlowFile will be routed to the associated relationship. If multiple expressions match a FlowFile's attributes, that FlowFile will be cloned and routed to each corresponding relationship. If none of the supplied expressions matches for a given FlowFile, that FlowFile will be routed to the 'unmatched' relationship.
| Modifier and Type | Field and Description |
|---|---|
static Relationship |
REL_MATCH |
static Relationship |
REL_NO_MATCH |
static AllowableValue |
ROUTE_ALL_MATCH |
static AllowableValue |
ROUTE_ANY_MATCHES |
static java.lang.String |
ROUTE_ATTRIBUTE_KEY |
static AllowableValue |
ROUTE_PROPERTY_NAME |
static PropertyDescriptor |
ROUTE_STRATEGY |
| Constructor and Description |
|---|
RouteOnAttribute() |
| Modifier and Type | Method and Description |
|---|---|
java.util.Set<Relationship> |
getRelationships() |
protected PropertyDescriptor |
getSupportedDynamicPropertyDescriptor(java.lang.String propertyDescriptorName)
Used to allow subclasses to determine what PropertyDescriptor if any to
use when a property is requested for which a descriptor is not already
registered.
|
protected java.util.List<PropertyDescriptor> |
getSupportedPropertyDescriptors()
Allows subclasses to register which property descriptor objects are
supported.
|
protected void |
init(ProcessorInitializationContext context)
Provides subclasses the ability to perform initialization logic
|
void |
onPropertyModified(PropertyDescriptor descriptor,
java.lang.String oldValue,
java.lang.String newValue)
Hook method allowing subclasses to eagerly react to a configuration
change for the given property descriptor.
|
void |
onScheduled(ProcessContext context)
When this processor is scheduled, update the dynamic properties into the map
for quick access during each onTrigger call
|
void |
onTrigger(ProcessContext context,
ProcessSession session) |
onTriggergetControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTruecustomValidate, equals, getPropertyDescriptor, getPropertyDescriptors, hashCode, validateclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetPropertyDescriptor, getPropertyDescriptors, validatepublic static final java.lang.String ROUTE_ATTRIBUTE_KEY
public static final AllowableValue ROUTE_PROPERTY_NAME
public static final AllowableValue ROUTE_ALL_MATCH
public static final AllowableValue ROUTE_ANY_MATCHES
public static final PropertyDescriptor ROUTE_STRATEGY
public static final Relationship REL_NO_MATCH
public static final Relationship REL_MATCH
protected void init(ProcessorInitializationContext context)
AbstractSessionFactoryProcessorinit in class AbstractSessionFactoryProcessorcontext - in which to perform initializationpublic java.util.Set<Relationship> getRelationships()
getRelationships in interface ProcessorgetRelationships in class AbstractSessionFactoryProcessorprotected java.util.List<PropertyDescriptor> getSupportedPropertyDescriptors()
AbstractConfigurableComponentgetSupportedPropertyDescriptors in class AbstractConfigurableComponentprotected PropertyDescriptor getSupportedDynamicPropertyDescriptor(java.lang.String propertyDescriptorName)
AbstractConfigurableComponentUsed to allow subclasses to determine what PropertyDescriptor if any to use when a property is requested for which a descriptor is not already registered. By default this method simply returns a null descriptor. By overriding this method processor implementations can support dynamic properties since this allows them to register properties on demand. It is acceptable for a dynamically generated property to indicate it is required so long as it is understood it is only required once set. Dynamic properties by definition cannot be required until used.
This method should be side effect free in the subclasses in terms of how often it is called for a given property name because there is guarantees how often it will be called for a given property name.
Default is null.
getSupportedDynamicPropertyDescriptor in class AbstractConfigurableComponentpropertyDescriptorName - used to lookup if any property descriptors exist for that namepublic void onPropertyModified(PropertyDescriptor descriptor, java.lang.String oldValue, java.lang.String newValue)
AbstractConfigurableComponentonPropertyModified in interface ConfigurableComponentonPropertyModified in class AbstractConfigurableComponentdescriptor - of the modified propertyoldValue - non-null property value (previous)newValue - the new property value or if null indicates the property
was removed@OnScheduled public void onScheduled(ProcessContext context)
context - ProcessContext used to retrieve dynamic propertiespublic void onTrigger(ProcessContext context, ProcessSession session)
onTrigger in class AbstractProcessor