Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Simple Nifi 1.6.0 Wait/Notify example

Simple Nifi 1.6.0 Wait/Notify example

New Contributor

To test the Nifi wait/notify processors I have the following simple example:

Getfile -> Wait -> Putfile -> Notify

So, I get some files from the getfile. I want to, one by one, put them into the putfile folder (obviously, I don't need the wait/notify processor here to do this.

So, I'd expect the getfile to get all of the files at once and hand them onto the wait. It never leaves the wait, is my problem.

i'm not getting any warnings, I have the DistributedMapCacheClientService setup as well as the DistributedMapCacheServer. I've assigned a Release Signal Identifier to the wait and notify of "release". All else is defaults.

What am I missing?

Thanks all,

---=L

4 REPLIES 4

Re: Simple Nifi 1.6.0 Wait/Notify example

Hi @Laurie McIntosh

This is expected. Data Flows in your example are blocked at the Wait processor hence there's no flowfile going through the Putfile and then Notify to unblock the file blocked in the wait. Notify is never triggered here. You need to have your Notify in an independent flow with the triggering logic.

Thanks

Re: Simple Nifi 1.6.0 Wait/Notify example

New Contributor

Right... what I'm trying to do is setup a gate here... so the first file trips the gate (the Wait) and stops the rest flowing through, and then the first file hits the second gate (the Notify) and leaves the flow, allowing the next file to flow through. I thought the Wait/Notify pair would do that.

If not, how can I do that?

Re: Simple Nifi 1.6.0 Wait/Notify example

Something you can do is to trigger a first Notify manually and let the gate do the rest. For instance, you can use a Generateflowfile with a notify for initial triggering and stop it afterward. This works but I don't know if there's a better way to do it. If the idea is to control flows, take a look at control rate processor which can be helpful.

68482-screen-shot-2018-04-16-at-12821-pm.png

Re: Simple Nifi 1.6.0 Wait/Notify example

New Contributor

You know when you first start coding in a language and you keep piling code on top of code to make something simple happen and it feels wrong because it shouldn't be this hard? This feels a bit like that... so I need a notify to open the gate in the first instance and then the second notify opens the gate again when the thing leaves? What if something else flows past the first notify while the process is still running? It just feels... odd. Not saying it's wrong, but it feels crufty.

What I'm looking for is something like, when count(waits) = count(notifys), let the file through.

So, at the start, count(Waits) = count(Notifys) (0 = 0), so the first file goes through. Now count(waits) = count(Notifys) + 1, so the files stop. First file leaves the flow, so Count(Waits) = count(Notifys) so next file runs.

That's a pretty specific use case, so another way to think about it is (and I'd have thought this would be a pretty standard Wait/Notify usage) is traffic lights - the "wait" is green by default and then turns red when a file passes and turns green again when the notify is tripped.