RabbitMQ
RabbitMQ Channel Integration
📦 Installation
npm install @nestjstools/messaging @nestjstools/messaging-rabbitmq-extension
# or
yarn add @nestjstools/messaging @nestjstools/messaging-rabbitmq-extension🧩 Basic Configuration Example
import { MessagingModule } from '@nestjstools/messaging';
import { MessagingRabbitmqExtensionModule, RmqChannelConfig, ExchangeType } from '@nestjstools/messaging-rabbitmq-extension';
import { SendMessageHandler } from './handlers/send-message.handler';
@Module({
imports: [
MessagingRabbitmqExtensionModule,
MessagingModule.forRoot({
messageHandlers: [SendMessageHandler],
buses: [
{ name: 'message.bus', channels: ['my-channel'] },
{ name: 'command-bus', channels: ['amqp-command'] },
{ name: 'event-bus', channels: ['amqp-event'] },
],
channels: [
new InMemoryChannelConfig({ name: 'my-channel' }),
new RmqChannelConfig({
name: 'amqp-command',
connectionUri: 'amqp://guest:guest@localhost:5672/',
exchangeName: 'my_app_command.exchange',
exchangeType: ExchangeType.TOPIC,
queue: 'my_app.command',
bindingKeys: ['my_app.command.#'],
autoCreate: true,
}),
new RmqChannelConfig({
name: 'amqp-event',
connectionUri: 'amqp://guest:guest@localhost:5672/',
exchangeName: 'my_app_event.exchange',
exchangeType: ExchangeType.TOPIC,
queue: 'my_app.event',
bindingKeys: ['my_app_event.#'],
autoCreate: true,
avoidErrorsForNotExistedHandlers: true,
}),
],
debug: true,
}),
],
})
export class AppModule {}🛠 Exchange Types
Exchange Type
Description
🔁 Cross-Language Messaging
🪦 Dead Letter Queue (DLQ) – How It Works
Behavior:
🔁 Example Use Case:
🔧 Configuration Table: AmqpChannelConfig
AmqpChannelConfigProperty
Description
Default
✉️ Custom Routing with AmqpMessageOptions
Mapping Messages in RabbitMQ Channels
Topic Exchange
Direct Exchange
Fanout Exchange
Last updated