Support Questions

Find answers, ask questions, and share your expertise

Why use replaceNull when setting a value in Nifi updateAttribute

New Contributor

New to Nifi here. I was looking at this post. that talks about how to make a retry flow. In it there is a updateAttribute that sets the variable `retry.counter` to ${retrycounter:replaceNull('0'):plus(1)}. How come they set it to that instead of 1? This is the beginning of the flow and should always be 1, no? A similar thing is done with retry.maxcoutner - `${retry_maxcount:replaceNull('3')}`

Please help me understand the logic behind this.



Master Guru

@Micah Pearce

There are numerous ways to accomplish the same result in NiFi.
The use of the ${retry.counter:replaceNull('0'):plus(1)} NiFi Expression language statement is to create an attribute with value 1 if attribute "retry.counter" does not exist on the FlowFile; otherwise, the existing value currently assigned to existing attribute "retry.counter" is returned and incremented by 1.
If we just set it to one, each time the same FlowFile passes through this loop it would get set to 1 and would never increment.


Thank you,