Skip to content

Commit 70837c8

Browse files
Merge pull request #2486 from CDelgrange/improve-cqrs-event-handler-doc
docs(cqrs): add some hint about event handler usage
2 parents ea61a42 + a60d5d6 commit 70837c8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

content/recipes/cqrs.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,12 @@ export class HeroKilledDragonHandler implements IEventHandler<HeroKilledDragonEv
224224

225225
Now we can move the **write logic** into the event handlers.
226226

227+
> info **Hint** Be aware that when you start using event handlers you get out of the traditional HTTP web context.
228+
> - Errors in `CommandHandlers` can still be caught by built-in [Exception filters](/exception-filters).
229+
> - Errors in `EventHandlers` can't be caught by Exception filters: you will have to handle them manually. Either by a simple `try/catch`, using [Sagas](/recipes/cqrs#sagas) by triggering a compensating event, or whatever other solution you choose.
230+
> - HTTP Responses in `CommandHandlers` can still be sent back to the client.
231+
> - HTTP Responses in `EventHandlers` cannot. If you want to send information to the client you could use [WebSocket](/websockets/gateways), [SSE](/techniques/server-sent-events), or whatever other solution you choose.
232+
227233
#### Sagas
228234

229235
This type of **Event-Driven Architecture** improves application **reactiveness and scalability**. Now, when we have events, we can simply react to them in various ways. **Sagas** are the final building block from an architectural point of view.

0 commit comments

Comments
 (0)