A transport of your own — Microservices · NestJS

Carry the cats service's messages over something Nest has no transporter for: the shelter's message bus. Write the server strategy that finds and runs the handlers, and the client proxy that publishes requests, matches their replies and dispatches events, then plug both in without touching a handler.

What you will learn

Read the theory for A transport of your own

All Microservices lessons

All NestJS courses

loading types…

What you'll learn

  • Write a CustomTransportStrategy: a Server subclass whose listen() receives messages and hands them to the handlers Nest registered, found with getHandlerByPattern()
  • Reply through Server.send() and transformToObservable(), so values, promises, streams and errors all become WritePackets
  • Write a ClientProxy subclass: publish() with a callback for each reply and a teardown, dispatchEvent() for events, connect() and close()
  • Plug both in with createMicroservice's strategy and ClientsModule's customClass, and know that handlers and callers do not change