breakpoint with timer

Hello!
I’m developing a workflow to get information from one api. My problem is that after running for a while the connection with the api get’s slower and my workflow stops saying the connection his lost. What I was trying to do was, put a “timer” in the middle of the loop that, after 1000 iterations, the loop stops for 5 min, and then starts again where it were stopped.
Is that possible?

Sorry for my english…

Yes!

You need to do something like this:

image

Replace the Generic Loop Start with whichever your start loop is, and the Column Rename with your api call.

The Java Edit Variable (simple) is configured as below, so that ever 1000th iteration the ‘Wait’ node is activated via the Flow Variable IF Switch (Flow Variable Value) node (from the Vernalis Community contribution) - which is configured as shown

image

image

Hope that helps

Steve

4 Likes

Thank for your answer!! It will help a lot!

Can you explain why use the “% 1000” on the return expression? And if i want to do for more than one value? like 1000, 2000, and so on?

1 Like

Forget it! I understood it now! the “%1000” is for every 1000th iterations!! Working pretty good! Thanks a lot

2 Likes

Good. Unfortunately, that does mean it will wait on the first (i.e. 0th) iteration too - you could modify the Edit Variable node to something like:

return $${IcurrentIteration}$$ == 0 ? 1 : $${IcurrentIteration}$$ % 1000;

This would return 1 on the 0th iteration (and so not do the wait), and the remainder on every subsequent iteration. (If you are not familiar with it, the 'test condition' ? 'true result' : 'false result' notation means if the 'test condition' is true, then return the 'true result', otherwise return the 'false result' (it’s a shorthand in java for if/then)

Steve

2 Likes