public final class Saga
extends java.lang.Object
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.
}
Modifier and Type | Class and Description |
---|---|
static class |
Saga.CompensationException |
static class |
Saga.Options |
Constructor and Description |
---|
Saga(Saga.Options options) |
Modifier and Type | Method and Description |
---|---|
void |
addCompensation(Functions.Func<?> operation)
Add compensation operation for saga.
|
<A1> void |
addCompensation(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> void |
addCompensation(Functions.Func3<A1,A2,A3,?> operation,
A1 arg1,
A2 arg2,
A3 arg3)
Add compensation operation for saga.
|
<A1,A2,A3,A4> |
addCompensation(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> |
addCompensation(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> |
addCompensation(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.
|
void |
addCompensation(Functions.Proc operation)
Add compensation operation for saga.
|
<A1> void |
addCompensation(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> void |
addCompensation(Functions.Proc3<A1,A2,A3> operation,
A1 arg1,
A2 arg2,
A3 arg3)
Add compensation operation for saga.
|
<A1,A2,A3,A4> |
addCompensation(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> |
addCompensation(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> |
addCompensation(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 |
compensate() |
public Saga(Saga.Options options)
public void compensate()
public void addCompensation(Functions.Proc operation)
operation
- to be executed during compensation.public <A1> void addCompensation(Functions.Proc1<A1> operation, A1 arg1)
operation
- to be executed during compensation.arg1
- first operation function parameterpublic <A1,A2> void addCompensation(Functions.Proc2<A1,A2> operation, A1 arg1, A2 arg2)
operation
- to be executed during compensation.arg1
- first operation function parameterarg2
- second operation function parameterpublic <A1,A2,A3> void addCompensation(Functions.Proc3<A1,A2,A3> operation, A1 arg1, A2 arg2, A3 arg3)
operation
- to be executed during compensation.arg1
- first operation function parameterarg2
- second operation function parameterarg3
- third operation function parameterpublic <A1,A2,A3,A4> void addCompensation(Functions.Proc4<A1,A2,A3,A4> operation, A1 arg1, A2 arg2, A3 arg3, A4 arg4)
operation
- to be executed during compensation.arg1
- first operation function parameterarg2
- second operation function parameterarg3
- third operation function parameterarg4
- fourth operation function parameterpublic <A1,A2,A3,A4,A5> void addCompensation(Functions.Proc5<A1,A2,A3,A4,A5> operation, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5)
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 parameterpublic <A1,A2,A3,A4,A5,A6> void addCompensation(Functions.Proc6<A1,A2,A3,A4,A5,A6> operation, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6)
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 parameterpublic void addCompensation(Functions.Func<?> operation)
operation
- to be executed during compensation.public <A1> void addCompensation(Functions.Func1<A1,?> operation, A1 arg1)
operation
- to be executed during compensation.arg1
- first operation function parameterpublic <A1,A2> void addCompensation(Functions.Func2<A1,A2,?> operation, A1 arg1, A2 arg2)
operation
- to be executed during compensation.arg1
- first operation function parameterarg2
- second operation function parameterpublic <A1,A2,A3> void addCompensation(Functions.Func3<A1,A2,A3,?> operation, A1 arg1, A2 arg2, A3 arg3)
operation
- to be executed during compensation.arg1
- first operation function parameterarg2
- second operation function parameterarg3
- third operation function parameterpublic <A1,A2,A3,A4> void addCompensation(Functions.Func4<A1,A2,A3,A4,?> operation, A1 arg1, A2 arg2, A3 arg3, A4 arg4)
operation
- to be executed during compensation.arg1
- first operation function parameterarg2
- second operation function parameterarg3
- third operation function parameterarg4
- fourth operation function parameterpublic <A1,A2,A3,A4,A5> void addCompensation(Functions.Func5<A1,A2,A3,A4,A5,?> operation, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5)
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 parameterpublic <A1,A2,A3,A4,A5,A6> void addCompensation(Functions.Func6<A1,A2,A3,A4,A5,A6,?> operation, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6)
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