Skip to content

Files

Latest commit

596d76f · Jun 23, 2019

History

History

sample07

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Dec 25, 2018
Jan 27, 2019
Feb 2, 2019
Dec 25, 2018
Jun 23, 2019

Saga Transaction sample

Illustrates how to implement an saga transaction with compensating steps, should an unhandled exception occur within the saga.

@Override
public void build(WorkflowBuilder<Object> builder) {        
    builder
        .startsWithAction(context -> System.out.println("begin"))
        .saga(saga -> saga
            .startsWith(Task1.class)
                .compensateWith(UndoTask1.class)
            .then(Task2.class)
                .compensateWith(UndoTask2.class)
            .then(Task3.class)
                .compensateWith(UndoTask3.class)
        )
        .thenAction(context -> System.out.println("end")); 
}