@EventDriven @SideEffectFree @SupportsBatching @InputRequirement(value=INPUT_REQUIRED) @Tags(value={"attributes","routing","Attribute Expression Language","regexp","regex","Regular Expression","Expression Language","find","text","string","search","filter","detect"}) @CapabilityDescription(value="Routes FlowFiles based on their Attributes using the Attribute Expression Language") @DynamicProperty(name="Relationship Name", value="Attribute Expression Language", expressionLanguageScope=FLOWFILE_ATTRIBUTES, 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 |
---|---|
private String |
configuredRouteStrategy |
private Set<String> |
dynamicPropertyNames |
private List<PropertyDescriptor> |
properties |
private Map<Relationship,PropertyValue> |
propertyMap
Cache of dynamic properties set during
onScheduled(ProcessContext) for quick access in
onTrigger(ProcessContext, ProcessSession) |
static Relationship |
REL_MATCH |
static Relationship |
REL_NO_MATCH |
private AtomicReference<Set<Relationship>> |
relationships |
static AllowableValue |
ROUTE_ALL_MATCH |
static AllowableValue |
ROUTE_ANY_MATCHES |
static String |
ROUTE_ATTRIBUTE_KEY |
static AllowableValue |
ROUTE_PROPERTY_NAME |
static PropertyDescriptor |
ROUTE_STRATEGY |
private static String |
routeAllMatchValue |
private static String |
routeAnyMatches |
private static String |
routePropertyNameValue |
Constructor and Description |
---|
RouteOnAttribute() |
Modifier and Type | Method and Description |
---|---|
Set<Relationship> |
getRelationships() |
protected PropertyDescriptor |
getSupportedDynamicPropertyDescriptor(String propertyDescriptorName) |
protected List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
protected void |
init(ProcessorInitializationContext context) |
void |
onPropertyModified(PropertyDescriptor descriptor,
String oldValue,
String newValue) |
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) |
onTrigger
getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrue
customValidate, equals, getPropertyDescriptor, getPropertyDescriptors, hashCode, validate
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getPropertyDescriptor, getPropertyDescriptors, validate
public static final String ROUTE_ATTRIBUTE_KEY
private static final String routeAllMatchValue
private static final String routeAnyMatches
private static final String routePropertyNameValue
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
private AtomicReference<Set<Relationship>> relationships
private List<PropertyDescriptor> properties
private volatile String configuredRouteStrategy
private volatile Map<Relationship,PropertyValue> propertyMap
onScheduled(ProcessContext)
for quick access in
onTrigger(ProcessContext, ProcessSession)
protected void init(ProcessorInitializationContext context)
init
in class AbstractSessionFactoryProcessor
public Set<Relationship> getRelationships()
getRelationships
in interface Processor
getRelationships
in class AbstractSessionFactoryProcessor
protected List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors
in class AbstractConfigurableComponent
protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName)
getSupportedDynamicPropertyDescriptor
in class AbstractConfigurableComponent
public void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue)
onPropertyModified
in interface ConfigurableComponent
onPropertyModified
in class AbstractConfigurableComponent
@OnScheduled public void onScheduled(ProcessContext context)
context
- ProcessContext used to retrieve dynamic propertiespublic void onTrigger(ProcessContext context, ProcessSession session)
onTrigger
in class AbstractProcessor
Copyright © 2021 Apache NiFi Project. All rights reserved.