I have the same thoughts and at present I’m considering three options based on this topic:
- It should be only one message handler for given Event type per Endpoint
Endpoint_1
SendEmailConfirmationHandler : IHandleMessages<OrderPlacedEvent>
Handle(...) { ... }
Endpoint_2
SomeOtherNewThingThatTalksToAWebServiceHandler : IHandleMessaged<OrderPlacedEvent>
Handle(...) { ... }
- In a given Endpoint there should be one message handler for given Event type responsible for initializing independent work
Endpoint_1
OrderPlacedEventHandler : IHandleMessages<OrderPlacedEvent>
Handle(...)
{
context.Send(SendEmailConfirmation)
context.Send(SomeOtherNewThingThatTalksToAWebService)
}
SendEmailConfirmationHandler : IHandleMessages<SendEmailConfirmation>
Handle(...) { ... }
SomeOtherNewThingThatTalksToAWebServiceHandler: IHandleMessaged<SomeOtherNewThingThatTalksToAWebService>
Handle(...) { ... }
- In a given Endpoint each indepentend work should have the own message handler for given Event type initializing the work
Endpoint_1
SendEmailConfirmationHandlers
OrderPlacedEventHandler :
IHandleMessages<OrderPlacedEvent>,
IHandleMessages<SendEmailConfirmation>
Handle(OrderPlacedEvent) { context.Send(SendEmailConfirmation) }
Handle(SendEmailConfirmation) { ... }
SomeOtherNewThingThatTalksToAWebServiceHandlers
OrderPlacedEventHandler :
IHandleMessages<OrderPlacedEvent>
IHandleMessaged<SomeOtherNewThingThatTalksToAWebService>
Handle(OrderPlacedEvent) { context.Send(SomeOtherNewThingThatTalksToAWebService) }
Handle(SomeOtherNewThingThatTalksToAWebService) { ... }
Back to your questions
I think the short answers are: no, no and no The reason - flexibility. We should be able to design logically independent components in any way especially using events no matter which logical Endpoint will be own the component. From the physical (runtime) point of view, sometimes, like in this scenario, we have to do a little bit extra work to minimize physical dependencies.