Class Saga
java.lang.Object
io.temporal.workflow.Saga
This class implements the logic to execute compensation operations that is
often required in Saga applications. The following is a skeleton to show of how it is supposed to
be used in workflow code:
Saga saga = new Saga(options);
try {
String r = activity.foo();
saga.addCompensation(activity::cleanupFoo, arg2, r);
Promise r2 = Async.function(activity::bar);
r2.thenApply(r->saga.addCompensation(activity.cleanupBar(r));
...
useR2(r2.get());
} catch (Exception e) {
saga.compensate();
// Other error handling if needed.
}
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic final class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCompensation(Functions.Func<?> operation) Add compensation operation for saga.<A1> voidaddCompensation(Functions.Func1<A1, ?> operation, A1 arg1) Add compensation operation for saga.<A1,A2> void addCompensation(Functions.Func2<A1, A2, ?> operation, A1 arg1, A2 arg2) Add compensation operation for saga.<A1,A2, A3>
voidaddCompensation(Functions.Func3<A1, A2, A3, ?> operation, A1 arg1, A2 arg2, A3 arg3) Add compensation operation for saga.<A1,A2, A3, A4>
voidaddCompensation(Functions.Func4<A1, A2, A3, A4, ?> operation, A1 arg1, A2 arg2, A3 arg3, A4 arg4) Add compensation operation for saga.<A1,A2, A3, A4, A5>
voidaddCompensation(Functions.Func5<A1, A2, A3, A4, A5, ?> operation, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5) Add compensation operation for saga.<A1,A2, A3, A4, A5, A6>
voidaddCompensation(Functions.Func6<A1, A2, A3, A4, A5, A6, ?> operation, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6) Add compensation operation for saga.voidaddCompensation(Functions.Proc operation) Add compensation operation for saga.<A1> voidaddCompensation(Functions.Proc1<A1> operation, A1 arg1) Add compensation operation for saga.<A1,A2> void addCompensation(Functions.Proc2<A1, A2> operation, A1 arg1, A2 arg2) Add compensation operation for saga.<A1,A2, A3>
voidaddCompensation(Functions.Proc3<A1, A2, A3> operation, A1 arg1, A2 arg2, A3 arg3) Add compensation operation for saga.<A1,A2, A3, A4>
voidaddCompensation(Functions.Proc4<A1, A2, A3, A4> operation, A1 arg1, A2 arg2, A3 arg3, A4 arg4) Add compensation operation for saga.<A1,A2, A3, A4, A5>
voidaddCompensation(Functions.Proc5<A1, A2, A3, A4, A5> operation, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5) Add compensation operation for saga.<A1,A2, A3, A4, A5, A6>
voidaddCompensation(Functions.Proc6<A1, A2, A3, A4, A5, A6> operation, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6) Add compensation operation for saga.void
-
Constructor Details
-
Saga
-
-
Method Details
-
compensate
public void compensate() -
addCompensation
Add compensation operation for saga.- Parameters:
operation- to be executed during compensation.
-
addCompensation
Add compensation operation for saga.- Parameters:
operation- to be executed during compensation.arg1- first operation function parameter
-
addCompensation
Add compensation operation for saga.- Parameters:
operation- to be executed during compensation.arg1- first operation function parameterarg2- second operation function parameter
-
addCompensation
public <A1,A2, void addCompensationA3> (Functions.Proc3<A1, A2, A3> operation, A1 arg1, A2 arg2, A3 arg3) Add compensation operation for saga.- Parameters:
operation- to be executed during compensation.arg1- first operation function parameterarg2- second operation function parameterarg3- third operation function parameter
-
addCompensation
public <A1,A2, void addCompensationA3, A4> (Functions.Proc4<A1, A2, A3, A4> operation, A1 arg1, A2 arg2, A3 arg3, A4 arg4) Add compensation operation for saga.- Parameters:
operation- to be executed during compensation.arg1- first operation function parameterarg2- second operation function parameterarg3- third operation function parameterarg4- fourth operation function parameter
-
addCompensation
public <A1,A2, void addCompensationA3, A4, A5> (Functions.Proc5<A1, A2, A3, A4, A5> operation, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5) Add compensation operation for saga.- Parameters:
operation- to be executed during compensation.arg1- first operation function parameterarg2- second operation function parameterarg3- third operation function parameterarg4- fourth operation function parameterarg5- fifth operation function parameter
-
addCompensation
public <A1,A2, void addCompensationA3, A4, A5, A6> (Functions.Proc6<A1, A2, A3, A4, A5, A6> operation, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6) Add compensation operation for saga.- Parameters:
operation- to be executed during compensation.arg1- first operation function parameterarg2- second operation function parameterarg3- third operation function parameterarg4- fourth operation function parameterarg5- fifth operation function parameterarg6- sixth operation function parameter
-
addCompensation
Add compensation operation for saga.- Parameters:
operation- to be executed during compensation.
-
addCompensation
Add compensation operation for saga.- Parameters:
operation- to be executed during compensation.arg1- first operation function parameter
-
addCompensation
Add compensation operation for saga.- Parameters:
operation- to be executed during compensation.arg1- first operation function parameterarg2- second operation function parameter
-
addCompensation
public <A1,A2, void addCompensationA3> (Functions.Func3<A1, A2, A3, ?> operation, A1 arg1, A2 arg2, A3 arg3) Add compensation operation for saga.- Parameters:
operation- to be executed during compensation.arg1- first operation function parameterarg2- second operation function parameterarg3- third operation function parameter
-
addCompensation
public <A1,A2, void addCompensationA3, A4> (Functions.Func4<A1, A2, A3, A4, ?> operation, A1 arg1, A2 arg2, A3 arg3, A4 arg4) Add compensation operation for saga.- Parameters:
operation- to be executed during compensation.arg1- first operation function parameterarg2- second operation function parameterarg3- third operation function parameterarg4- fourth operation function parameter
-
addCompensation
public <A1,A2, void addCompensationA3, A4, A5> (Functions.Func5<A1, A2, A3, A4, A5, ?> operation, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5) Add compensation operation for saga.- Parameters:
operation- to be executed during compensation.arg1- first operation function parameterarg2- second operation function parameterarg3- third operation function parameterarg4- fourth operation function parameterarg5- fifth operation function parameter
-
addCompensation
public <A1,A2, void addCompensationA3, A4, A5, A6> (Functions.Func6<A1, A2, A3, A4, A5, A6, ?> operation, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6) Add compensation operation for saga.- Parameters:
operation- to be executed during compensation.arg1- first operation function parameterarg2- second operation function parameterarg3- third operation function parameterarg4- fourth operation function parameterarg5- fifth operation function parameterarg6- sixth operation function parameter
-