paed01 / bpmn-engine

BPMN 2.0 execution engine. Open source javascript workflow engine.
MIT License
860 stars 166 forks source link

What if the server has to restart and the engine was waiting for a timer to complete #152

Closed BaluprasathSBP closed 2 years ago

BaluprasathSBP commented 2 years ago

bpmn-engine is synchronous in nature. For an instance, Engine is executing the intermediate timer workflow. It has to wait for 2 days to start the next activity. Assume the state is saved when the workflow reaches timer. What if the server is down now and restarted, we would have lost the engine now but we have state saved in database. How does the timer works now? will it start from again 0? How will it continue?

paed01 commented 2 years ago

The timer event has a started at state that will be compared with Date.now() when it resumes. Hence, when the workflow is resumed and the timer has expired the timer event will complete immediately.