Event timer with exponential duration

I would like to put my requirement first.

I have a user task which is taking some information and sending it to another service. Now I need to keep checking if the information is validated or not. If its validated successfully then I would continue with my task.

So for this I created one service task which is “poll for status”, now what I want to keep polling until I get a success or failure result or my counter expires.

What I did so far is to put an intermediate event timer between user task and my polling task, and then after polling task I am checking if validation success or not, if not, go back to timer.

So here I want help on 2 things.

  1. Is there any way to keep counter for Modeler side or I need to manage using process variable?
  2. Is there any way for timer duration to be exponential from Modeler side or I need to manage using process variable?

I am also putting my current implementation in modeler for better understanding.

Hi Team,

any update on this?

Thanks & Regards!
Vineet Saxena

Your timer can take an expression. One idea would be to keep a counter as a process variable and calculate the delay in the expression. If that’s too much for an expression, you can delegate it to a method and just call that one instead.

1 Like

Hi Vineet,

Another pattern you could use is the job executor’s retry cycles. To use this you need to set the Poll service task to be asynchronous (before) in the modeller. To get exponential behaviour, yiu can enter a list of retry cycle timers in the retry time cycle field in the service task config. Something like; PT1M,PT2M,PT5M Thus the job will poll throw an exception and wait 1 min before trying again, then wait for 2 mins and so on…

This also assumes that if the poll logic does not get a result, your service task throws an exception which the job executor will catch and schedule the job for retry. If the job executor runs out of retries, an incident will be created. You probably need to think about wht you want the process to do if your poll strategy fails - do you want to log an incident for support folk to manage, or route the process to a user task for business users to resolve…

regards

Rob

1 Like

Hi Rob,

Firstly thank you very much for the response, and I change my implementation accordingly and no more using timer event, instead using retries.

All looks ok except one thing, how to send the flow to a user task once all retries fails.
I am using HTTP connector in my service task and in the response, I am throwing exception if status code is not 200, and then retry is happening.

So now only thing left is to redirect the process to a user task after all retries done.

Please help to guide me to the place where I could check how it needs to be done?

Thanks!
Vineet Saxena

Hi Vineet -

if you want to route to a user task after the retry strategy fails, you could use the pattern as per this thread.

Its quite a sophisticated pattern, so use with caution. The way it works is you keep track of the number of retries and when you get to the last retry, rather than let the job executor catch the exception which would result in an incident, you throw a BPMN error which could then route to a user task for remediation for example…

regards

Rob