Support Questions

Find answers, ask questions, and share your expertise

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

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.

avatar

@umair ahmed

Here is a template of the above flow.

counter-to-delay-on-loop.xml

avatar
Contributor

@Wynner

In ExecuteStreamCommand processor command path= ' usr/bin/sleep' what is this thing because i am getting exception in ExecuteStreamCommand processor .."The System cannot find the file specified"

and i am using windows

thanks

umair

avatar

@umair ahmed

That is a command in Unix, to wait the amount of time specified, 30 seconds, one minute whatever is specified. The Windows equivalent is timeout I believe, so just replace the command.

avatar
Contributor

@Wynner

usr/bin/sleep is seem a directory structure

so i have to replace usr/bin/sleep to timeout only

or something else can you give me an example

thanks

umair

avatar

@umair ahmed

Correct, just replace /usr/bin/sleep with timeout.

What version of Windows are you using?

avatar
Contributor

@Wynner

windows 10 version 1703

but now after replacing to timeout i am getting error invalid value for timeout(/T) specified .valid range id -1 to 9999

avatar
Contributor
  • 15241-screenshot-4.pngi getting this error now

avatar
Contributor

@wynner

i am using your template

and now it is firing after every 30 sec for 5 counts

InvokeHTTP Penalty Duration is 30 sec as per my requirement everything is in your template already but it is not working as i want to