Microservice Transports: Redis, MQTT & NATS
Microservice Transports: Redis, MQTT & NATS
The earlier microservices lessons covered TCP, RabbitMQ, Kafka, and gRPC. NestJS also supports Redis, MQTT, and NATS transporters, each aimed at different messaging needs and operational tradeoffs.
Core idea
This feature is about controlling how the application is organized and how it behaves at runtime. These are the points a developer should understand before using it in a real project:
- Redis transport is simple for lightweight pub/sub-style communication but is not the same as durable Redis Streams.
- MQTT is common for IoT and device messaging where topics and constrained clients matter.
- NATS is lightweight, fast, and well suited for service messaging with subject-based routing.
- Transport choice affects delivery guarantees, back pressure, ordering, observability, and operations.
- ClientProxy abstracts the client API, but each driver still has different connection and deployment behavior.
Practical example
The following example shows the idea in a practical NestJS project. The goal is not to memorize the snippet, but to understand where it belongs in the architecture:
Production checklist
- Document delivery expectations for every message pattern.
- Set connection status monitoring for clients and servers.
- Design idempotent consumers for at-least-once transports.
- Avoid using pub/sub transports for workflows that require durable replay unless the broker supports it.
Summary
This lesson covers an advanced NestJS area that matters when building enterprise applications. Focus on clear boundaries, testable behavior, and choosing the right tool for the context instead of using every feature everywhere.