Note that there are some explanatory texts on larger screens.

plurals
  1. POSaga that depend on events from the past
    text
    copied!<p>I have a question how to deal with a saga where the decision making depends on an event that was published before the saga was created.</p> <p>Here is an example to illustrate my issue:</p> <p>Imagine I have a CustomerAR and a OrderAR. When the customerAR is created a validation process starts, the result of that process is the amount of an order that the customer is free to spend without special authorization. I will not go into detail about this process because it's out of context. When the amount is calculated a command is sent to the the CustomerAR with the calculated amount and the CustomerAR publishes an event (CustomerMaxOrderAmountEvent) with that value. So far so good.</p> <p>Then a few weeks later the customer places an order. The OrderAR is created and starts my OrderSaga. The saga waits until the order is created completely and then has to make a decision if it needs to send an AutorizationCommand for that order. To make that decision it has to know if the CustomerMaxOrderAmountEvent is published and the value of the amount. Normally the OrderSaga will also subscribe to the CustomerMaxOrderAmountEvent, but the problem is this event will never occur because it already did in the past.</p> <p>How should I deal with this. Should I query the read model to know the value, should I send a command to get the value, should I make a reference to the CustomerAR, should I replay all historic events in the saga so he knows the history already.</p> <p><strong>UPDATE</strong></p> <p>Please note that it's about the concept not about this concrete example. The example is pure for clarification of the problem: "2 non related aggregate roots that are not part of the same bounded context."</p> <p>Thankful for help.</p> <p>Melvin </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload