Created 05-08-2017 06:53 AM
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
Created on 05-08-2017 01:34 PM - edited 08-17-2019 06:50 PM
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:
Here is the configuration of the UpdateAttribute processor
The advanced UI in the RouteOnAttribute can be used to set the delay time using an attribute
Here is the configuration of the RouteOnAttribute processor
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.
You can adjust for your need.
Created 05-09-2017 03:47 PM
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.
Created 05-09-2017 05:02 PM
@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
Created on 05-09-2017 05:54 PM - edited 08-17-2019 06:50 PM
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:
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.
Created 05-10-2017 05:10 AM
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
Created 05-10-2017 12:33 PM
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.
Created 05-10-2017 01:03 PM
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.
Created 05-10-2017 02:24 PM
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
Created 05-10-2017 02:43 PM
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.
Created on 05-10-2017 12:49 PM - edited 08-17-2019 06:50 PM
UpdateAttribute processor advanced UI configuration
Here is the configuration of the RouteOnAttribute processor
Created 05-10-2017 01:48 PM
i removed unit form second value now i am getting this error
"execution.error ERROR: Cannot wait for the specified signal"