How to create a graceful kill-switch


Hi guys, I have been trying to model a kill switch for instance. As show in diagram I have list of tasks that are performed sequentially, the continuity of these tasks depends on an external system. When a trigger(api call to system that is handling the process) is raised by the external system the process should stop whatever it is doing and do some updations (based on that data it gets from external system) and call it a day.
What I have done :
I will take the trigger data and throw an interrupting message event so that the error handler can do necessary updations. The message includes error reason and other data provided by the external system that will be used by error handler task.
The problem is that when message event is published task 1 is interrupted(assuming) and error handler will finish, task1 is resumed and then i will get “Command ‘COMPLETE’ rejected with code ‘NOT_FOUND’” exception because instance is already ended.

What I want to know is there any way to discard the task altogether when it was interrupted and don’t resume it. I can catch this particular exception and suppress it, but is there any better way to handle this.
I also tried to use the Error message event, but I couldn’t use it because the logic that is throwing the message event doesn’t have access to Job Client and plus I think data/variables can’t be sent while throwing Error event
Thanks in advance

Hi @keviv,

try to mark each service task with “Asynchronous before”.

You can find some background information here: Transactions in Processes | docs.camunda.org

Hope this helps, Ingo