title | summary | component | reviewed | related | |||
---|---|---|---|---|---|---|---|
Publish and Handle an Event |
How to define, publish, and handle events |
Core |
2024-01-12 |
|
Event messages need to either implement IEvent
or match a custom DefiningEventsAs
convention. See the message design documentation for more details.
In order to handle an event, implement the IHandleMessages<T>
interface in any handler or saga class, where T
is the specific event type.
Call the Publish
method to publish an event.
There are a few common scenarios for publishing events. Events might be published:
- from a handler, when processing another message.
snippet: publishFromHandler
- from a saga handler, when processing another message.
snippet: publishFromSaga
- at endpoint startup
snippet: publishAtStartup
In order to support advanced composition scenarios, events can be defined as interfaces. See the Messages as Interfaces for more details.