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

How to wait one processor upto another processor completes its task

How to wait one processor upto another processor completes its task

Explorer

17652-drawing-1.jpeg

drawing-1.jpegHi, I have a requirement to to wait one processor upto another processor complets its task

1.Let say I have a json array ,which contains the 6 json objects, i am splitting the json array so then i have 6 flowfiles

2.These 6 flowfiles one by one sending to the invokeHttp processor and get the 6 responses .Here i need to check the last response if its success then i need to start the another processor

3.I have attached the diagram representation ,please find.

In Nifiprocessor box which one i should use.Could you please provide the solution ?

Thanks

4 REPLIES 4

Re: How to wait one processor upto another processor completes its task

@siva karna

You could the RouteOnAttribute processor. The SplitJson processor writes two attributes to each flow file that can be used to know when the last split flow file reaches the RouteOnAttribute file. fragment.count = The number of split FlowFiles generated from the parent FlowFile and fragment.index = A one-up number that indicates the ordering of the split FlowFiles that were created from a single parent FlowFile (this value starts at 0 for the first flow file) , so in your case, the last flow file would have fragment.index value of 5. So, you could use the expression language to determine when the last flow file arrived to the RouteOnAttribute processor.

Here is an example of how you would use the fragment.count and the fragment.index attributes:

16682-screen-shot-2017-07-04-at-41750-pm.png

Any flow file where the values result in a false will be routed out the unmatched relationship. The one flow file where the result will be true is routed out the nextprocessor relationship.

Re: How to wait one processor upto another processor completes its task

Explorer

Thank You Wynner for ur response. i will try

Re: How to wait one processor upto another processor completes its task

Explorer

@siva karna

Why not use the wait and notify processor?

Redirect the original file to wait processor from the splitJson processor.

In the wait processor set the Target Signal Count to ${fragment.count}.

Set the Release Signal Identifier in both the notify and wait processor to ${fragment.identifier}

Now start the flow. The SplitJson will split the flow file and redirect the original flow file to the wait processor. It will wait there until the target signal count i.e in this case fragment.count number of fragements have been notified by the notify processor.

Please try to construct a flow like below

17665-screen-shot-2017-07-05-at-120036-pm.png

Hope this helps

Re: How to wait one processor upto another processor completes its task

Explorer

Thank You mkalyanpur for ur response and i will try