Files
main.tsmain
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
Press Run tests to start the app. Its log appears here.Graded endpoints
The gateway publishes 'cat.adopted' and answers 202 at once: it does not wait for the service, because an event has no reply
The event reached the service, and the handler in CatsController recorded the adopter
NoticesController handles 'cat.adopted' too: every handler registered for an event pattern receives it
Another event, another id: the handlers read the payload they were sent
Still 202: the gateway cannot know, because nothing comes back from an event. The service ignores an id it does not know
Milo's adoption was announced, and nothing was announced for the unknown cat
Luna was never adopted; Tom and Milo were