This is the official NestJS documentation page for the Redis transporter in the microservices module. It describes how to use Redis as a message broker for inter-service communication using the publish/subscribe paradigm, with ioredis as the underlying driver.

Key takeaways

  • The Redis transporter implements pub/sub messaging: messages are fire-and-forget with no delivery guarantee.
  • Install ioredis and configure via Transport.REDIS in createMicroservice() or ClientsModule.register().
  • Supported options: host, port, retryAttempts, retryDelay, wildcards.
  • Enable wildcards with the wildcards: true option to use psubscribe/pmessage for pattern-based subscriptions (e.g., @EventPattern('notifications.*')).
  • Access request context via RedisContext (imported from @nestjs/microservices), exposing getChannel().
  • Subscribe to connection status via client.status stream: emits connected, disconnected, reconnecting.
  • Listen to internal Redis events with client.on('error', ...) or server.on<RedisEvents>('error', ...).
  • Access the underlying ioredis driver with unwrap(), which returns a tuple [pubClient, subClient] — one for publishing and one for subscribing.

Entities and concepts

Connections to existing knowledge

This is the authoritative source for Redis-based microservices in NestJS. It covers the messaging/broker use case, distinct from the caching use cases described in How to add Redis cache to a NestJS app and Using Redis Client in NestJS. The Transport.REDIS from @nestjs/microservices is unrelated to the CacheModule approach used for HTTP response caching. A separate copy of this same content exists under the title “NestJS - A progressive Node.js framework” (also from docs.nestjs.com).