Compesation VS Transaction

I am a rookie in Camunda BPMN, and I follow the tutorial demo GitHub - berndruecker/trip-booking-saga-java: Example implementation of the Saga pattern for the classic trip booking example using the lightweight open source workflow engine (Camunda). to build a workflow to test the mechanism of transaction and compensation in camunda.

I have build my own demo like this:


In the workflow I defined, when the workflow reached the Receive Task named “Save Point”, the status of the workflow will be saved in DB. After message received, the workflow will continue and it will throw a Exception in “Exception Step”.

I expect that the thrown exception will trigger the error start event in the event-subprocess to complete the compensation steps and the transaction of the main process will roll back to the Receive Task “Save Point”.

However the reality is that the compensation task will be executed but the main process will finish.

I have learn that the compensation and error event is interrupting, which means it will end the current workflow.

So I wonder if there is any solution to perform both compensation and transaction rollback in such situation?

Thanks for your help
And looking forward to your reply

Hi,

Theres a few things going on here, so lets divide and conquer. To address your proposed model;

If you throw a BPMN Error in your exception step, then it looks like you will trigger the interrupting event driven subprocess. Hence this interrupts your main process flow and thus you will not return to your check point. To return to the check point, you would need to model and explicit flow back to it…

Im not sure if you mean throw a technical exception. If so, and in conjunction with asynchronous continuations and rollback strategy, its possible to roll back to your checkpoint.

You need to be clear on which transaction you are talking about - there is a business bpmn transaction construct which usually involves compensation handlers. Then there is ‘transaction’ defined by the engine in terms of executions which create checkpoints in the engines database. Then there are database transactions (which are usually tightly coupled to the engine executions). Hence please clarify which transaction you are referring to…

regards

Rob

Hi,
Thanks for your reply!

there are some point I should say clearly.

  1. the exception I throw in my workflow is a technical exception, which is just a subclass of Java Exception.
  2. the transaction I mean here is the database transaction. The reason I want the transaction to rollback is that in my scenario, when my delegate code throw a exception, the compensation handler should be invoke to fix the business data and meanwhile the status of the workflow should be restored to the last save point.

Im not sure what does you mean by “in conjunction with asynchronous continuations and rollback strategy, its possible to roll back to your checkpoint.”

Is there any example for this?
I will go back to look into the section about asynchronous continuation.

Thanks again for your reply.
And looking forward to your new reply!