Events — Microservices · NestJS

Publish what happened instead of asking for an answer: the gateway emits a 'cat.adopted' event and answers 202 at once, and two handlers in the cats service react to it, each for its own purpose.

What you will learn

Read the theory for Events

All Microservices lessons

All NestJS courses

loading types…

What you'll learn

  • Tell request-response from events: a message waits for a reply, an event is published and nobody answers
  • Handle events with @EventPattern, and register more than one handler for the same event
  • Publish with ClientProxy.emit(), a hot Observable that sends whether or not anyone subscribes, unlike send()
  • Answer 202 Accepted for work that happens after the response, and know what the caller cannot learn from an event