Support Questions

Find answers, ask questions, and share your expertise

PutFile

avatar
Explorer

I have a use case as below:-

 

I have files to be transferred using Nifi flow as ListFile->FetchFile->PutFile processor.

 

But I want the PutFile processor to execute/trigger only if a given condition is true (let's say if the attribute value of the flow file is equal to given value). Please tell me how to achieve this and what processor must be placed between FetchFile and PutFile processor in the above-given flow.

1 REPLY 1

avatar
Master Mentor

@Ankit13 

 

The PutFile is going to execute base on its configured run schedule (Timer Driven Execution) or cron schedule (Cron Driven Execution).  If you are adding an attribute to the FlowFile that you are using to evaluate a boolean true or false, the best approach is to add a RouteOnAttribute processor between your FetchFile and PutFile processors to redirect those FlowFiles where your condition does not resolve to "true". In this way you selectively decide which FlowFiles to pass to the putFile to be executed upon.

As far as the RouteOnAttribute, it will have an unmatched relationship and you add dynamic properties which become new relationships that can be associated with different connections.  

You can use NiFi Expression Language (NEL) [1] to construct a boolean statement to evaluate your routing condition.

 

[1] https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html

If you found this response assisted with your query, please take a moment to login and click on "Accept as Solution" below this post.

Thank you,

Matt