Skip to content

Commit

Permalink
update after saga context added
Browse files Browse the repository at this point in the history
Signed-off-by: Sky Ao <[email protected]>
  • Loading branch information
skyao committed Jan 13, 2024
1 parent e786009 commit e9d85a9
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public WorkflowStub create() {
ctx.complete(orderResult);
return;
}
ctx.registerCompensation(ProcessPaymentCompensationActivity.class.getName(), paymentRequest);
ctx.getSagaContext().registerCompensation(ProcessPaymentCompensationActivity.class.getName(), paymentRequest);

// step5: Update the inventory (need compensation)
inventoryResult = ctx.callActivity(UpdateInventoryActivity.class.getName(),
Expand All @@ -96,12 +96,12 @@ public WorkflowStub create() {
ctx.callActivity(NotifyActivity.class.getName(), notification).await();

// trigger saga compensation gracefully
ctx.compensate();
ctx.getSagaContext().compensate();
orderResult.setCompensated(true);
ctx.complete(orderResult);
return;
}
ctx.registerCompensation(UpdateInventoryCompensationActivity.class.getName(), inventoryRequest);
ctx.getSagaContext().registerCompensation(UpdateInventoryCompensationActivity.class.getName(), inventoryRequest);

// step6: delevery (allways be failed to trigger compensation)
ctx.callActivity(DeliveryActivity.class.getName()).await();
Expand Down

0 comments on commit e9d85a9

Please sign in to comment.