(Not) Saga about Sagas

Mirosław Pragłowski / @mpraglowski

@arkency

what is the pain

Saga helps to deal with eventual consistency, uncertainty and constraint prohibiting transactions going outside of the Aggregate Root (or entity in general). Sagas are aware of the passing time and can implement functionality like timeouts.

what is saga

Saga is a message handler running on the server, that helps us to implement long-running business transactions. Sagas can subscribe to events and receive direct commands. They send commands. Usually implemented as finite state machine.

diff aggregate root and saga

Sagas listen to events and dispatch commands while aggregates receive commands and publish events.

btw...

saga has state

a little bit of history

Introduced in paper written by Hector Garcia-Molina and Kenneth Salem in 1987 (http://www.cs.cornell.edu/andru/cs711/2002fa/reading/sagas.pdf).

how to...

saga: shipment data (correlation id: order id)
    OrderCreated    =>
    CustomerBilled  =>
    ShipmentReady   =>
                    => ShipOrder
    CancelOrder     =>
                    => OrderShipped / RefundOrder
  

read, read more...

  • http://www.udidahan.com/2009/04/20/saga-persistence-and-event-driven-architectures/
  • https://skillsmatter.com/skillscasts/1631-udi-dahan-cqrs-race-conditions-and-sagas
  • http://abdullin.com/post/theory-of-cqrs-command-handlers-sagas-ars-and-event-subscrip/
  • http://blog.jonathanoliver.com/cqrs-sagas-with-event-sourcing-part-i-of-ii/
  • http://blog.jonathanoliver.com/cqrs-sagas-with-event-sourcing-part-ii-of-ii/
  • http://vasters.com/clemensv/2012/09/01/Sagas.aspx
  • http://martinfowler.com/eaaDev/EventSourcing.html
  • http://msdn.microsoft.com/en-us/library/jj591569.aspx

Available at

https://talks.praglowski.com/not-saga-about-sagas/