paed01 / bpmn-engine

BPMN 2.0 execution engine. Open source javascript workflow engine.
MIT License
884 stars 167 forks source link

Update executed timer #170

Open rusaym opened 1 year ago

rusaym commented 1 year ago

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 1 year ago

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

rusaym commented 1 year ago

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 1 year ago

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 1 year ago

Thank you for suggestions

rusaym commented 1 year ago

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

paed01 commented 1 year ago

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 1 year ago

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

paed01 commented 1 year ago

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 1 year ago

Could you please provide some example how to do that?