Support Questions
Find answers, ask questions, and share your expertise

NiFi Count Fileflows via attribute

Solved Go to solution

NiFi Count Fileflows via attribute

Expert Contributor

I'm trying to achieve a simple count on fileflows via attribute. The idea is to count to 100, then execute an email. How do I achieve this?

1 ACCEPTED SOLUTION

Accepted Solutions

Re: NiFi Count Fileflows via attribute

@Joe

One way to accomplish this is via a groovy script, created by @Matt Burgess, ran in the ExecuteScript processor. The script waits until there are 100 flow files in the incoming connection and then sends 99 out the success relationship and the 100th flow file out the failure which connects to a PutEmail process, which sends an email, and then passes the 100th file back into the normal flow path.

27457-screen-shot-2017-08-14-at-42448-pm.png

Groovy script in the ExecuteScript processor, this script would go into the Script Body property:

27458-screen-shot-2017-08-14-at-42603-pm.png

View solution in original post

3 REPLIES 3

Re: NiFi Count Fileflows via attribute

@Joe

One way to accomplish this is via a groovy script, created by @Matt Burgess, ran in the ExecuteScript processor. The script waits until there are 100 flow files in the incoming connection and then sends 99 out the success relationship and the 100th flow file out the failure which connects to a PutEmail process, which sends an email, and then passes the 100th file back into the normal flow path.

27457-screen-shot-2017-08-14-at-42448-pm.png

Groovy script in the ExecuteScript processor, this script would go into the Script Body property:

27458-screen-shot-2017-08-14-at-42603-pm.png

View solution in original post

Re: NiFi Count Fileflows via attribute

@Matt Burgess @Wynner 
I have a similar kind of issue while counting the flowfiles from the compresscontent processor , my use case is 

I have a flow in which I wait for 5 files that  should come out from  the respective CompressContentProcessors, after which I start another processor. if the count is less or more than 5, I have to send out an email.if the count is 5 i will continue with the flow. I have tried using unpack content processor but it doesnt support the format that i have my files in . Can anyone please suggest what would be the good option to get this thing done?

Thanks,

Aquib 

Re: NiFi Count Fileflows via attribute

@aquib_mohammed 

What is the format of the files?