You dont have invariants/rules in the eventhandler. The entity/aggregate//whatever that generated the event is reponsible for this.
Also, you most certianly dont want to include a full aggregate in your event. How would this be persisted? (unless you’re doing the orm + domainevents pattern, I guess you could make it work on a technical level then. Doesn’t mean you should)
/Peter
--
You received this message because you are subscribed to the Google Groups "DDD/CQRS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dddcqrs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "DDD/CQRS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dddcqrs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "DDD/CQRS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dddcqrs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
If your AR is Customer { Id, Email, Name }, then by all means, put it in an event (there are several other reason not to do this, but based purely on the content, fine). The term crudsourcing seems appriate for this.
But if it doesn’t look like that, and is more about behaviour than storing data, how are you going to use it in your eventhandler? To execute domainlogic?
/Peter
--
Dont put entities on the wire.
Like I wrote, the are several reasons not to. But if you’re doing crud (and I don’t think this is eventsourced or have any behaviour, or the question wouldn’t have come up), and use loose schema, there’s a footgun and a pair of scissors at you’re disposal that might be fun to play around with ;-)
/Peter
I’m afraid your missing the point:
If you really have a behavioural domainmodel, you wouldn’t have much use for an AR in your eventhandler. If you don’t, there are more suitable patterns for dealing with your data (crud, etc).
(there’s an old thread in this group about storing crud-data as events to keep operational complexity down (which I think is a valid concern), I suggest you read it)
This is very confused. Id spend some more time reading etc and implementing in test projects before moving forward on a work project
Have a look at Greg’s (?) SimpleCQRS. It’s a lot easier to get a grasp of, than the P&P Journey (wich I found rather confusing and very focused on infrastructure)
@enrico - loading an Aggregate Root in an event handler just doesn't make sense. I don't mean technically. You can move bits around any way you like. But the purpose of an Aggregate Root is to encapsulate data and behavior.
It's hard for me to find the right words to express the disconnect. It would be like talking about feeding grapes to a mountain so it can survive a journey to Mars.Most of the time when I have a desire to put a lot of data on an event, I find that1) my boundaries are off2) i'm doing crud, so be it3) haven't properly captured previous events in the consuming context.For instance, if you had previously published "CustomerCreated", why would you need to add all that data in this subsequent event?
It has nothing to do with the language, it has to do with what seems to be a fundamental misunderstanding of the concepts on your part. What are you trying to accomplish here?The flow starts with:
- User -> Command -> Command Handler -> AR1 -> Event
and then you are saying you want to do:
- Event -> Event Handler -> Command -> Command Handler -> AR2
You say that to process the last Command, you either need all the data from AR1 on the Event or you need to load AR1 in the Command Handler. There are a few things to be said about this:
- AR1 is for behavior/writing, not reading. You would read from a Read Model if you needed additional data.
- Read Models are created from Events
- AR generally do not keep all their state, only the state needed to make decisions in the future.
- The Event data is used to create the Command here, you do not send an Event to an AR.
- If AR2 needs all of AR1 data, you likely have a modelling issue.
Like people have been saying, go back and do some more reading and create some examples.
Again , Thank u 2 for the suggestion .. b.t.w. : One of the take aways I can get from my first readings on this forum , and not only, is that there are hardly 2 ppl that agree on most subjects :)