How to rollback a task in Camunda

Hi,
I am new working with Camunda, I have the following process, in both tasks there are injections to a DB.
is there a way to rollback the process from task 2 to the start event, including the rollback in the DB and in camunda process?

PD: sorry for my English.

Hi @sftr,

Transaction sub-process, cancel event along with cancel boundary event could be used to group multiple activities into a transaction. (You should implement the compensation “rollback” logic yourself).
Compensation is only triggered for activities that have been completed.

Kindly find attached a simplified working example
test_compensation_process.bpmn (7.2 KB)

You can try the `createProcessInstanceModification()`API.

runtimeService.createProcessInstanceModification(processInstanceId)
					.cancelAllForActivity("task2")
					.startBeforeActivity("task1")
					.execute();

Thank u, this works perfectly.

1 Like