-
Notifications
You must be signed in to change notification settings - Fork 764
Compensating Workflows Pattern #4665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v1.16
Are you sure you want to change the base?
Conversation
Signed-off-by: Cassandra Coyle <[email protected]>
Signed-off-by: Cassandra Coyle <[email protected]>
@marcduiker - Let's think over a diagram we could add into the docs and presentation deck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've created a diagram for this, but this will be part of another PR since I want to update all the workflow related diagrams #4679 .
@@ -1386,6 +1386,195 @@ func raiseEvent() { | |||
|
|||
External events don't have to be directly triggered by humans. They can also be triggered by other systems. For example, a workflow may need to pause and wait for a payment to be received. In this case, a payment system might publish an event to a pub/sub topic on receipt of a payment, and a listener on that topic can raise an event to the workflow using the raise event workflow API. | |||
|
|||
## Compensation | |||
|
|||
The compensation pattern provides a mechanism for rolling back or undoing operations that have already been executed when a workflow fails partway through. This pattern is particularly important for long-running workflows that span multiple microservices where traditional database transactions are not feasible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The compensation pattern provides a mechanism for rolling back or undoing operations that have already been executed when a workflow fails partway through. This pattern is particularly important for long-running workflows that span multiple microservices where traditional database transactions are not feasible. | |
The compensation pattern (also known as the saga pattern) provides a mechanism for rolling back or undoing operations that have already been executed when a workflow fails partway through. This pattern is particularly important for long-running workflows that span multiple microservices where traditional database transactions are not feasible. |
ctx.getLogger().info("Order shipped: {}", shipmentId); | ||
compensations.add("CancelShipment"); | ||
|
||
// Step 4: Send confirmation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to remove this activity. It's a bit confusing now if the SendConfirmation throws, then the rest is still compensated.
Adding docs for a new workflow pattern: compensating workflows
I added a java example here. This is just a first pass implementation that could be improved upon, but wanted to document the new pattern
@hhunter-ms can you add a diagram to my PR and tweak it as you see fit?