File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
src/main/java/com/uber/cadence/samples/hello Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -80,17 +80,19 @@ public static class SagaWorkflowImpl implements SagaWorkflow {
80
80
public void execute () {
81
81
Saga saga = new Saga (new Saga .Options .Builder ().setParallelCompensation (false ).build ());
82
82
try {
83
+ // The following demonstrate how to compensate sync invocations.
83
84
ChildWorkflowOperation op1 = Workflow .newChildWorkflowStub (ChildWorkflowOperation .class );
84
85
op1 .execute (10 );
85
86
ChildWorkflowCompensation c1 = Workflow .newChildWorkflowStub (ChildWorkflowCompensation .class );
86
87
saga .addCompensation (c1 ::compensate , -10 );
87
88
89
+ // The following demonstrate how to compensate async invocations.
88
90
Promise <Void > result = Async .procedure (activity ::execute , 20 );
89
- result .get ();
90
91
saga .addCompensation (activity ::compensate , -20 );
92
+ result .get ();
91
93
92
- // The following is just to demonstrate the ability of supplying arbitrary lambda as a
93
- // saga compensation function. In production code please always use Workflow.getLogger
94
+ // The following demonstrate the ability of supplying arbitrary lambda as a saga
95
+ // compensation function. In production code please always use Workflow.getLogger
94
96
// to log messages in workflow code.
95
97
saga .addCompensation (() -> System .out .println ("Other compensation logic in main workflow." ));
96
98
throw new RuntimeException ("some error" );
You can’t perform that action at this time.
0 commit comments