> For the complete documentation index, see [llms.txt](https://docs.nestjstools.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nestjstools.com/broker-integration/redis.md).

# Redis

### 🧩 Redis Channel Integration

The Redis extension for `@nestjstools/messaging` enables your NestJS application to send and receive asynchronous messages through Redis-backed queues. This is especially useful for lightweight messaging setups or when using Redis as a shared infrastructure component.

***

#### 📦 Installation

Install the core and Redis messaging packages:

```bash
npm install @nestjstools/messaging @nestjstools/messaging-redis-extension
```

or

```bash
yarn add @nestjstools/messaging @nestjstools/messaging-redis-extension
```

***

#### ⚙️ Example Configuration

```ts
import { MessagingModule } from '@nestjstools/messaging';
import { MessagingRedisExtensionModule, RedisChannelConfig } from '@nestjstools/messaging-redis-extension';
import { InMemoryChannelConfig } from '@nestjstools/messaging/channels';
import { SendMessageHandler } from './handlers/send-message.handler';

@Module({
  imports: [
    MessagingRedisExtensionModule,
    MessagingModule.forRoot({
      messageHandlers: [SendMessageHandler],
      buses: [
        {
          name: 'message.bus',
          channels: ['my-channel'],
        },
        {
          name: 'command.bus',
          channels: ['redis-command'],
        },
        {
          name: 'event.bus',
          channels: ['redis-event'],
        },
      ],
      channels: [
        new InMemoryChannelConfig({
          name: 'my-channel',
          middlewares: [],
          avoidErrorsForNotExistedHandlers: true,
        }),
        new RedisChannelConfig({
          name: 'redis-command',
          queue: 'command-queue',
          connection: {
            host: '127.0.0.1',
            port: 6379,
          },
          middlewares: [],
          avoidErrorsForNotExistedHandlers: false,
        }),
        new RedisChannelConfig({
          name: 'redis-event',
          queue: 'event-queue',
          connection: {
            host: '127.0.0.1',
            port: 6379,
          },
          middlewares: [],
          avoidErrorsForNotExistedHandlers: true,
        }),
      ],
      debug: true,
    }),
  ],
})
export class AppModule {}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.nestjstools.com/broker-integration/redis.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
