Toivo,
There are a few ways to tackle this.
You can do essentially what you’re discussing here with the RouteOnAttribute
and UpdateAtribute Processors. On failure, you can route to UpdateAttribute. In
UpdateAttribute, add a property named “retryCount” and a value of
“${retryCount:replaceNull(0):plus(1)}”. Then send that to RouteOnAttribute.
RouteOnAttribute has a property added named “retry” with a value of
“${retryCount:le(3)}”. Then, you connect the “retry” relationship back to your
processor and route “unmatched” to wherever you want to go if you’ve finished
retrying.
Alternatively, you could just RouteOnAttribute and add a property named “retry”
with a value of “${now():minus( ${entryDate} ):lt( 300000 )}”, which tells it
to send to retry if the FlowFile is less than 5 minutes old. Then you don’t
need to increment anything but you retry for 5 minutes rather than retrying up
to 3 times.
Also, Jenn Barnabee, one of the contributors, has a blog where she’s written a
lot of stuff about how to do little tasks like this in NiFi. She illustrates a
similar method for doing this here:
https://kisstechdocs.wordpress.com/2015/01/15/creating-a-limited-failure-loop-in-nifi/
Really, we should probably consider making this simpler by having a
CountRetries processors that has two relationships: “Retry”, “No More Retries”
and just lets you configure Proc A (failure) -> CountRetries (Retry) -> Proc A
and CountRetries (No More Retries) -> elsewhere.
Thanks
-Mark
From: [email protected]
Sent: Sunday, February 15, 2015 2:56 PM
To: Mark Payne
This is an automatically generated Delivery Status Notification.
Delivery to the following recipients failed.
[email protected]