2

I have two aggregate roots... AR1 and AR2. AR1 holds a collection of references (IDs) to instances of AR2. Inside one of the AR1 methods a domain event is raised to update the collection of AR2 instances. The domain event is raised after the transaction completes using a technique mentioned here: http://www.jayway.com/2013/06/20/dont-publish-domain-events-return-them everything works as expected.

My issue is this: The method I am calling from the domain event to update AR2 is currently public (can't be internal) as the domain event is executing in my application service layer (different assembly to my business logic layer). I only ever want this method executed by the domain event and nothing else.

How would I go about doing this?

Cool Breeze
  • 1,289
  • 11
  • 34
  • What's your major concern that points you in this direction? – JefClaes Nov 26 '14 at 09:37
  • my original thinking was I only ever wanted the command executed after an event has occurred... but obviously there must be something fundamentally wrong with my design? – Cool Breeze Nov 27 '14 at 05:19

1 Answers1

1

You could ask for event object as an argument to the AR2 method. That will be a good indicator that the method should only be called as the result of a raised event.

public void someMethod(SomeOccuredEvent event)

We can see this approach being used in Effective Aggregate Design Part III in the Implementing Eventual Consistency section.

plalx
  • 42,889
  • 6
  • 74
  • 90