Files
What you'll learn
- Return an Observable from a message handler to send several replies, and know that each one crosses the wire as it is emitted
- Read parts of a payload with @Payload('key') and the transport's context with @Ctx(), and know which arguments an undecorated handler receives
- Collect a stream on the client with toArray() and lastValueFrom(), and know why firstValueFrom() and returning the Observable from a route both answer with a single value
- Bound a call with the timeout() operator and turn its TimeoutError into a 504 at the gateway
Press Run tests to start the app. Its log appears here.Graded endpoints
The service emits one reply per match and the gateway collects them into one array, in the order they were sent
minAge travels as a number and the service keeps cats at least that old
Both keys of the payload are read: Siamese cats aged 3 or more
The stream completes without a single reply; toArray() makes that an empty array rather than an error
Without a breed or an age every cat matches, in the service's order
Two partner shelters answer in 200 ms, inside the gateway's 500 ms
Nine shelters take 900 ms; the gateway stops waiting at 500 ms and answers 504 instead of hanging
GET /cats/:id from the first lesson is unchanged, and /cats/search did not take its place
{ cmd: 'find-all' } still answers with a single reply that is an array, unlike the search's stream
The adoption event from the previous lesson is published as before
Both event handlers ran: Luna's adopter is recorded, and the stream carries the current records
NoticesController announced the adoption