differences between @eventhandler and @eventsourcinghandler

what are the differences between these two annotations?

Hi Qian Liu,

The EventSourcingHandler is on the command side’s Aggregate to dictate how the Aggregate will change, given that event. EventHandlers are normally on query applications/side to dictate what to do once an event has occurred. Strictly speaking, EventHandlers are optional (you are able to have the updated Aggregate (think of it a state machine), by going through the events in the event store, and updating it along the way through the EventSourcingHandlers.

Once an EventSourcingHandler has finished executing, the event is published to the EventBus, which is then caught by the EventHandlers.

Since event are typically named in past tense, I like to think of EventSourcingHandler as the present, and the EventHandler is the actually execution once the event is in the past. Hope this makes sense.

I recommend thinking of the concepts of Command and Query as two separate modules/services. Then, things like EventSourcingHandler vs EventHandler would make more sense, as if these are within the same module, they have very little differences ( in fact I rarely justify the use of EventHandlers in single module structures).