.startEvent() .compensateEventDefinition() .compensateEventDefinitionDone() .endEvent() .done();
public static BpmnModelInstance prepareCompensationEventProcess() { return Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .subProcess("subProcess") .embeddedSubProcess() .startEvent() .endEvent() .subProcessDone() .intermediateThrowEvent(FAILING_EVENT) .camundaAsyncBefore(true) .camundaFailedJobRetryTimeCycle(SCHEDULE) .compensateEventDefinition() .compensateEventDefinitionDone() .serviceTask() .camundaClass(FailingDelegate.class.getName()) .endEvent() .done(); }
.boundaryEvent("compensationBoundary1") .compensateEventDefinition() .compensateEventDefinitionDone() .moveToActivity("serviceTask1") .serviceTask("serviceTask2") .boundaryEvent("compensationBoundary2") .compensateEventDefinition() .compensateEventDefinitionDone() .moveToActivity("serviceTask2") .intermediateThrowEvent("compensationEvent") .compensateEventDefinition() .waitForCompletion(true) .compensateEventDefinitionDone() .endEvent() .done();
@SuppressWarnings("rawtypes") public SagaBuilder compensationActivity(String name, Class adapterClass) { if (!(saga instanceof AbstractActivityBuilder)) { throw new RuntimeException("Compensation activity can only be specified right after activity"); } String id = "Activity-" + name.replace(" ", "-") + "-compensation"; // risky thing ;-) ((AbstractActivityBuilder)saga) .boundaryEvent() .compensateEventDefinition() .compensateEventDefinitionDone() .compensationStart() .serviceTask(id).name(name).camundaClass(adapterClass.getName()) .compensationDone(); return this; }
public SagaBuilder triggerCompensationOnAnyError() { process.eventSubProcess() .startEvent("ErrorCatched").error("java.lang.Throwable") .intermediateThrowEvent("ToBeCompensated").compensateEventDefinition().compensateEventDefinitionDone() .endEvent("ErrorHandled"); return this; }
.startEvent("eventSubProcessStart") .compensateEventDefinition() .compensateEventDefinitionDone() .endEvent() .done());
.boundaryEvent("compensationBoundary") .compensateEventDefinition() .compensateEventDefinitionDone() .moveToActivity("userTask1") .subProcess("innerSubProcess") .compensateEventDefinition() .waitForCompletion(true) .compensateEventDefinitionDone() .done());
.compensateEventDefinition() .waitForCompletion(true) .compensateEventDefinitionDone() .done());
private void createCompensationFlow() { engine.getRepositoryService().createDeployment() // .addModelInstance("travel.bpmn", Bpmn.createProcess("travel").executable() // .startEvent() .serviceTask().name("Reserve car") //.camundaClass(ReserveCar.class) .boundaryEvent().compensateEventDefinition().activityRef("compensateCar").compensateEventDefinitionDone() .done() ).deploy(); } }
.boundaryEvent().compensateEventDefinition().compensateEventDefinitionDone() .compensationStart().serviceTask("CancelCar").camundaClass(CancelCarAdapter.class).compensationDone() .serviceTask("hotel").name("Book hotel").camundaClass(BookHotelAdapter.class) .boundaryEvent().compensateEventDefinition().compensateEventDefinitionDone() .compensationStart().serviceTask("CancelHotel").camundaClass(CancelHotelAdapter.class).compensationDone() .serviceTask("flight").name("Book flight").camundaClass(BookFlightAdapter.class) .boundaryEvent().compensateEventDefinition().compensateEventDefinitionDone() .compensationStart().serviceTask("CancelFlight").camundaClass(CancelFlightAdapter.class).compensationDone() .endEvent(); .intermediateThrowEvent().compensateEventDefinition().compensateEventDefinitionDone() .endEvent();
public static BpmnModelInstance prepareCompensationEventProcess() { return Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .subProcess("subProcess") .embeddedSubProcess() .startEvent() .endEvent() .subProcessDone() .intermediateThrowEvent(FAILING_EVENT) .camundaAsyncBefore(true) .camundaFailedJobRetryTimeCycle(SCHEDULE) .compensateEventDefinition() .compensateEventDefinitionDone() .serviceTask() .camundaClass(FailingDelegate.class.getName()) .endEvent() .done(); }
.startEvent() .compensateEventDefinition() .compensateEventDefinitionDone() .endEvent() .done();
.boundaryEvent("compensationBoundary1") .compensateEventDefinition() .compensateEventDefinitionDone() .moveToActivity("serviceTask1") .serviceTask("serviceTask2") .boundaryEvent("compensationBoundary2") .compensateEventDefinition() .compensateEventDefinitionDone() .moveToActivity("serviceTask2") .intermediateThrowEvent("compensationEvent") .compensateEventDefinition() .waitForCompletion(true) .compensateEventDefinitionDone() .endEvent() .done();
.startEvent("eventSubProcessStart") .compensateEventDefinition() .compensateEventDefinitionDone() .endEvent() .done());
.boundaryEvent("compensationBoundary") .compensateEventDefinition() .compensateEventDefinitionDone() .moveToActivity("userTask1") .subProcess("innerSubProcess") .compensateEventDefinition() .waitForCompletion(true) .compensateEventDefinitionDone() .done());
.compensateEventDefinition() .waitForCompletion(true) .compensateEventDefinitionDone() .done());