Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

NiFi: invokehttp retries

avatar
Contributor

Hi..

i am using invokeHttp processor to consume my rest api but whenever 5xx http error retrying back to same processor (invoke Http) but its hitting my infinite time ..i want to limit retry count 5 and it retry at certain time like first retry after 1 min and second after 30 min and vice versa ....thanks in advance

umair

1 ACCEPTED SOLUTION

avatar

@umair ahmed

You could use the UpdateAttribute and RouteOnAttribute processors to create additional attributes on the flow file that keep track on the number of times the file has looped on a particular relationship. Here is an example of a flow that keep track of every relationship but the original flow file in the InvokeHttp processor:

15199-screen-shot-2017-05-08-at-95644-am.png

Here is the configuration of the UpdateAttribute processor

15196-screen-shot-2017-05-08-at-93007-am.png

The advanced UI in the RouteOnAttribute can be used to set the delay time using an attribute

15200-screen-shot-2017-05-08-at-100106-am.png

Here is the configuration of the RouteOnAttribute processor

15197-screen-shot-2017-05-08-at-93109-am.png

The delay is done using the ExecuteStreamCommand processor and calling the sleep command with the appropriate value to wait for the next attempt in using the InvokeHttp processor.

15201-screen-shot-2017-05-08-at-100410-am.png

You can adjust for your need.

View solution in original post

22 REPLIES 22

avatar
@umair ahmed

I am not following you.

What do you mean by "firing every 30 sec for 5 counts"?

I just used the delay times as en example. How long do you want it to wait each time through?

In my template, iI did the first time 60 seconds, second time 30 minutes, third time 1 hour, fourth time two hours.

avatar
Contributor

@wynner

i mean by "firing every 30 sec for 5 counts"? that

invokehttp processor Penalty Duration is 30 second so every 30 second it retrying for service (for 5xx error)

and it is retrying 5 times

that is

1st retry after 30 sec

2nd retry after 1 min and so on till 5 count

i want to wait same as you said first time 60 seconds, second time 30 minutes, third time 1 hour, fourth time two hours then break the loop

but in my case it is not working

i think it is problem of windows

avatar

@umair ahmed

You are correct, it is a Windows problem. The timeout command does not work with input redirection.

So, use the waitfor command and it will work, here is a snapshot of the reconfigured ExecuteScriptCommand processor:

15261-screen-shot-2017-05-09-at-15005-pm.png

Even though it works, the waitfor command throws an error because the notanerror event never occurs before the time out period. Also, the sleeptime values have to be in seconds, not minutes or hours.

avatar
Contributor

@Wynner

not working i am getting error " or ERROR: Invalid syntax. Specify valid numeric value for '/T'. Type "WAITFOR /?" for usage." and i replace sleeptime value to second

avatar
@umair ahmed

What do you have in the property Command Arguments in the ExecuteStreamCommand processor?

Please take a snapshot the Properties tab for the ExecuteStreamCommand processor.

When I said you need to have the value in seconds for the sleeptime attribute, I meant inside the configuration of the advanced UI in the UpdateAttribute processor. In the template I uploaded, I was using minutes.

avatar

@umair ahmed

I see the issue. While the values for sleeptime are in seconds, do not put the unit in the value.

So, instead of 1800s, change that to 1800 and so on for the other values.

avatar

@umair ahmed

Try changing "notanerror" to something else and see if you still get the error. I just put that as an example.

Open a cmd window on your system and see if you can run the command outside of NiFi. Try something like, waitfor /T 10 test

avatar
@umair ahmed

Okay, that is the expected behavior.

Try the exact command in the ExecuteStreamCommand processor and see if it works? Just use the flow file as a trigger for the processor.

avatar
Contributor

@Wynner

UpdateAttribute processor advanced UI configuration15266-screenshot-6.png

15267-screenshot-7.png

15268-screenshot-8.png

Here is the configuration of the RouteOnAttribute processor15269-screenshot-9.png

avatar
Contributor

@Wynner

i removed unit form second value now i am getting this error

"execution.error ERROR: Cannot wait for the specified signal"