americanexpress/unify-flowret

Add capability to terminate a journey

Closed this issue · 3 comments

Given a process id forcibly terminate all of its current running steps.

Possible approach: steps will listen for 'request_terminate' event with 'termination_type' having allowed values 'soft' and 'immediate'. If 'soft' then on step end it will return OK_TERMINATE. If 'immediate' step will immediately return OK_TERMINATE. When a step returns OK_TERMINATE subsequent routes/steps will not be followed.

The component that may have been created and invoked by the step will continue running.

Yes, that is one way. But there is already a way today to do exactly what you are wanting, that is, by using the ticket functionality. You could have one step in the end and the running step could raise a ticket that transfers control to the last step and so for all practical purposes the process will get over.

However, if the requirement is to stop dead the running branch in its tracks and let the other branches run, then that is not a valid process in my opinion. A single threaded branch has to go all the way to completion and cannot just terminate anywhere in between. Parallel branches have to come to a join.

Lastly, if your requirement is to terminate a running process from outside, that could be built. But I would hesitate to do it while the process is running rather do it when the process has pended (which should be far simpler to do). Its usually not the case that we have a step which is long running and if it is then it should to be taken outside of the process as a batch or something else. I will add it as part of the back log to do for future.

The usecase is to terminate a process from outside.
Yes, it is risky with unknown side-effects unless, as you say, the process is in 'pend' state, but it would still be needed. eg: deal with unintentionally run-away process.

Flowret is an embedded orchestrator meaning that it runs in the application process. So if a terminate process functionality is required, it could be provided only when the process is pended. Will think more about this.