Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

NiFi Count Fileflows via attribute

avatar
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

avatar
@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

avatar
@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

avatar

@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 

avatar

@aquib_mohammed 

What is the format of the files?