eventhorizon icon indicating copy to clipboard operation
eventhorizon copied to clipboard

[doc] Create an example of a Saga for multiple aggregates

Open giautm opened this issue 7 years ago • 8 comments

Hi. I want to see an example of multiple aggregates in a project to see how they communicate. :)

giautm avatar Feb 15 '18 18:02 giautm

Sounds like it could be a good example. Could you describe in more detail what you would like to highlight?

maxekman avatar Feb 16 '18 19:02 maxekman

I want to see:

  • How two aggregate roots can communicate together.
  • How to use two aggregates in a domain service which require two aggregates to complete a command.

giautm avatar Feb 17 '18 01:02 giautm

Basically you should never have a command that directly affects multiple aggregate roots. If you need that you should probably create a saga that issues one of the commands as a side effect to an event from the first command.

Relating to your question, a more complex saga example could be good to have. I'll try to add that at some point.

maxekman avatar Feb 18 '18 21:02 maxekman

Tks, I will waiting for the example. May I contribute to that PR for learning?

giautm avatar Feb 19 '18 14:02 giautm

You can propose an example if you want to learn about it.

Maybe a e-commerce checkout could be a good example:

  • One simple domain called Order, with commands and events for Create, Fulfil and Reject.
  • One simple domain called Payment, with a command Request with events Accepted and Denied.
  • A saga that reacts on Order.Created and issues a Payment.Request command. It will then fulfil or reject the order depending on if the payment was accepted or denied.

maxekman avatar Mar 01 '18 08:03 maxekman

Idea is too have small aggregate. One aggregate does not have other aggregate instead it can have id of aggrgate. If u read akka actor model it says result of one aggrgate can be passed to other. Here one aggrgate result can be passed to other.

chaudharisuresh997 avatar Jul 05 '18 16:07 chaudharisuresh997

Shouldn't a saga be able to react on a bunch of events? Currently It's interface only relies on a single event only.

screwyprof avatar Feb 21 '19 21:02 screwyprof

In that case the saga has to keep track of incoming events until it has collected all affected events. Then it can continue processing. A saga is meant to keep its own internal state if required.

maxekman avatar Feb 22 '19 07:02 maxekman