DEV Community

Discussion on: Implementing the Saga Pattern in C#

Collapse
 
leol profile image
Леонид Ляшко

If you fall here await ReleaseInventory(order.ProductId, order.Quantity); you will not do this await CancelOrder(order.Id);

Collapse
 
dotnetfullstackdev profile image
DotNet Full Stack Dev

Thanks for your observation, but here we need to do both

  1. ReleaseInventory - for adjust offset in inventory side 2.CancelOrder - for adjust offset in order side

These two will do different adjustments when payment fails

Collapse
 
leol profile image
Леонид Ляшко

Sorry, but I mean something else. In saga we should not only suggest that operation can fail, but also think what if compensation operation fail.

Thread Thread
 
dotnetfullstackdev profile image
DotNet Full Stack Dev

No problem! We should learn together, and grow together!
If that is the case, then we have to think about different techniques to handle compensation operation failures
for ex :

  • Retry the Compensating Action
  • Compensate the Compensating Action
  • Design for Partial Consistency

likewise, we have a few alerting techniques as well

  • Triggering alerts for manual intervention.
  • Logging the failure for further diagnosis.
  • send the failed event/message to a Dead Letter Queue
  • Notify the user of the issue

Hope here I got you a few points for your question