Multiple Saga associations

Hi,

We currently have a Saga involved with two aggregates that have a one to many relationship. We can’t join them together due to other domain constraints.
Let’s call the first one the Problem aggregate. The second aggregate can be represented as the Mitigation aggregate. A Problem can have multiple Mitigations.

Is it possible for the ProblemSaga to listen to specific events of both the Problem and collection of the Mitigation aggregates? I would like to listen to a MitigationInvalidatedEvent in order to trigger invalidation of the Problem using the saga.

I know you can create associations with a different key and the same event property name (example with BuyOrder and SellOrder). But is it also possible to have multiple associations to Mitigations from that ProblemSaga? I noticed that the association_value_entry table contains a unique restraint on the sagaid and the associationkey combination.

Best regards and my thanks for creating and maintaining the Axon framework.

Hi Michael,

maybe I don’t understand your issue completely, but it seems that you aggregate/saga design could be improved. Lets say you have a MitigationInvalidatedSaga, which should handle also the Mitigations in the Problem Aggregate. Hold a reference to open mitigations (just the id’s) in your problem aggregate (e.g. List). As soon as the list has no mitigations, you could invalidate the problem.

I just follow these simple rules and they suit my very well.

  1. Consistency of domain object with their aggregate root’s are managed by the aggregate itself.
  2. Consistency between domain objects is managed by the sagas.

J

Hi Michael,

you say " I noticed that the association_value_entry table contains a unique restraint on the sagaid and the associationkey combination.". There is a key, but it should not be unique. You can indeed add multiple values for the same association key. The Saga will then simply be triggered for each event that matches at least one of the registered associations.

Cheers,

Allard

Hi Allard,

Thank you for the update! I verified the behaviour and indeed multiple values can be stored. The client I was using was showing the index as unique but I think the client has some issues with the mssql index info.

Best regards,

Michael