The Redis Transporter is a NestJS microservice transport layer that uses Redis pub/sub for inter-service messaging. Messages are published to channels and received by subscribed microservices.

How it works

  • Configured via Transport.REDIS in createMicroservice() or ClientsModule.register().
  • Uses ioredis under the hood — each client maintains two connections: one for publishing, one for subscribing.
  • Messages are fire-and-forget — if no subscriber exists, the message is discarded.

Key features

  • Wildcards: Enable pattern-based subscriptions with wildcards: true and patterns like 'notifications.*'.
  • Context: Access channel info via RedisContext.getChannel() in message handlers.
  • Status stream: Subscribe to client.status for connected, disconnected, reconnecting events.
  • Internal events: Listen to Redis events ('error', etc.) via client.on() or server.on<RedisEvents>().
  • Underlying driver: Access the ioredis instances via unwrap<[Redis, Redis]>(), returning [pubClient, subClient].

Contrast with caching use

The Redis Transporter is for messaging between services, not for caching. It is configured via @nestjs/microservices, not @nestjs/common’s CacheModule.