What are NestJS microservices and what transports are supported?
Answer
NestJS has first-class support for microservices through the @nestjs/microservices package. A microservice is created with NestFactory.createMicroservice() instead of the regular create(). Supported transports: TCP (simple, built-in), Redis (pub/sub), NATS, RabbitMQ, Kafka, gRPC, MQTT. Message handlers use @MessagePattern() or @EventPattern() decorators instead of HTTP method decorators. Services communicate by injecting a ClientProxy and using client.send(pattern, data) (request-response) or client.emit(pattern, data) (fire-and-forget). NestJS microservices abstract away transport details so you can switch transports with minimal code changes.
Previous
How does NestJS dependency injection scoping work?
Next
What is the ExecutionContext in NestJS?
More NestJS Questions
View all →- Intermediate How does NestJS dependency injection scoping work?
- Intermediate What is the ExecutionContext in NestJS?
- Intermediate How do you implement role-based access control (RBAC) in NestJS?
- Intermediate What is the Reflector in NestJS and how is it used?
- Intermediate How do you implement caching in NestJS?