-
Notifications
You must be signed in to change notification settings - Fork 9
Events
Ioan Crișan edited this page Mar 18, 2019
·
5 revisions
A special case of messages are events. Unlike typical message handling, for events there can be more than one handler.
- Publish events using the IEventPublisher service.
- Subscribe to events using the IEventHub service.
Events are published through the event publisher service.
var eventPublisher = compositionContext.GetExport<IEventPublisher>();
eventPublisher.Publish(new AppStartedEvent());See IdentifiableEvent.
The central point for event subscription is the event hub service.
var eventHub = compositionContext.GetExport<IEventHub>();
var subscription = eventHub.Subscribe<AppStartedEvent>((_, _, _) => this.Logger.Info("Application started"));
//...
subscription.Dispose();- An event is published through the event publisher service. Typically this is the DistributedEventPublisher implementation.
- The event is transported using the message broker.
- The EventHubMessageHandler endpoint receives the event and notifies all event hub subscribers.