paed01/bpmn-engine

Update executed timer

Opened this issue · 9 comments

rusaym commented

Hi!
I have a simple process with timer, user task and script task
image
By some time, if user didn't signal the user task, timer executes and the script task runs. Script task just notify user that it haven't done its task by the time.
So my question is, if it is any way to update the timer if its already executed, script ran and state updated? For example I want to give user more time to do its job.

paed01 commented

Have you tried a repeated duration - R3/PT10M? The user will be notified every 10 minutes, 3 times.

rusaym commented

For example I need a task to be done by June, 3, 10:00, but user haven't done the task on time and I need to reset timer to June 12, 10:00.
So implementation will be something like this?

  1. I get duration between now and June, 3, 10:00.
  2. Set Timer = R1/duration
  3. User haven't done the task on time, script change timer to Timer = R1/100years
  4. Than some day I realize, that user need time till June, 12, 10:00.
  5. I get duration between now and June, 12, 10:00.
  6. Set Timer = R1/duration
    and so on...
    Like that?
paed01 commented

I would suggest more than one non-interuptive timer pointing to the reminder. Or connect an interruptive timer event with a loopback to the user task again, perhaps with an expression that resolves to the required duration.

The repeated non-interruptive timer cannot be updated since it will repeat run with the resolved timeCycle duration.

rusaym commented

Thank you for suggestions

rusaym commented

Is there any way to update not repeated timer, that is not expired?

paed01 commented

Have you inspected environment.timers.executing? You could attempt to find your specific timer by the owner property. Not sure if it's the best solution but nevertheless.

rusaym commented

And after I got my timer how to set it's new expiration datetime?

paed01 commented

Well... not only that. What if the execution is recovered and resumed, then the updated timer is not persisted. Have you had a look at TimerEventDefinition source? With an overload effort you could try to send an api message to the timer that will stop the current and start a new timer.

rusaym commented

Could you please provide some example how to do that?