I’ve been attempting to understand how the compensation feature works with the bpmn model. I’ve reviewed the CompensateEventTest.testCompensateSubprocessWithUserTask model and replaced the user task with a service task with a simple system.out. I still can’t seem to get my compensation service task to be called. Here is the bpmn content:
<process id="mailpieceExtractionProcess" isExecutable="true"> <startEvent id="start"></startEvent> <subProcess id="scope" name="subProcess"> <startEvent id="startevent1" name="Start"></startEvent> <endEvent id="endevent2" name="End"></endEvent> <serviceTask id="servicetask1" name="Service Task" activiti:class="prince.SimpleJavaDelegateTask"></serviceTask> <sequenceFlow id="flow4" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow> <boundaryEvent id="boundarycompensation1" name="Compensate" attachedToRef="servicetask1" cancelActivity="true"> <compensateEventDefinition></compensateEventDefinition> </boundaryEvent> <serviceTask id="servicetask2" name="Service Task" isForCompensation="true" activiti:class="prince.SimpleJavaDelegate"></serviceTask> <sequenceFlow id="flow5" sourceRef="servicetask1" targetRef="endevent2"></sequenceFlow> <association id="association1" sourceRef="boundarycompensation1" targetRef="servicetask2" associationDirection="None"></association> </subProcess> <sequenceFlow id="flow1" sourceRef="start" targetRef="scope"></sequenceFlow> <endEvent id="endevent1" name="End"></endEvent> <intermediateThrowEvent id="compensationintermediatethrowevent1" name="CompensationThrowingEvent"> <compensateEventDefinition activityRef="scope"></compensateEventDefinition> </intermediateThrowEvent> <sequenceFlow id="flow2" sourceRef="scope" targetRef="compensationintermediatethrowevent1"></sequenceFlow> <sequenceFlow id="flow3" sourceRef="compensationintermediatethrowevent1" targetRef="endevent1"></sequenceFlow> </process>
I’m just calling the process without variables and all I get is the system.out from my [non-compensating] service task. Is there something I’m missing or not understanding?
Essentially, I’m looking to get to the point where I can use a transaction subprocess where tasks can be compensated if an error occurs. My thought is that this would work nicely as a rollback.