AnsweredAssumed Answered

Programmatically throwing a boundary compensation event

Question asked by krraghavan on Mar 10, 2016
I have the following use case.  I want to support the ability to cancel any arbitrary workflow which we primarily use for long running processes.  We want to abort the workflow around task boundaries (i.e. at the beginning of the next task).  The way I did this was:

1. Created a message intermediate catching event in the workflow that hooks into a service task.
2. The service task merely sets a process instance variable to true indicating that a cancel was requested.
3. At the beginning of the next task (we mainly use ServiceTasks with all extending a base class) I check whether the cancel variable is set to true.
4. If cancel is true I would like to throw a boundary compensation event that will then hook into a compensation handler.

Right now I have this working with a regular boundary error event that hooks into a service task.

Question:
1. Is the compensation handler the appropriate way to do this or is the method I have ok to use?
2. If compensation is the way to go, how can I programmatically throw that boundary compensation event (right now I throw a new BpmnError to trigger the boundary error event).

Thx
Raghavan

Outcomes