> For the complete documentation index, see [llms.txt](https://jakekwak.gitbook.io/nestjs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jakekwak.gitbook.io/nestjs/microservices/untitled-3.md).

# RabbitMQ

## RabbitMQ

[RabbitMQ](https://www.rabbitmq.com/)는 가장 널리 배포된 오픈 소스 메시지 브로커입니다.

## Installation

시작하기 전에 필요한 패키지를 설치해야합니다.

```bash
$ npm i --save amqplib amqp-connection-manager
```

## Transporter

**RabbitMQ** 전송기로 전환하려면 `createMicroservice()`메소드에 전달된 옵션 객체를 수정해야합니다.

```typescript
@@filename(main)
const app = await NestFactory.createMicroservice(ApplicationModule, {
  transport: Transport.RMQ,
  options: {
    urls: [`amqp://localhost:5672`],
    queue: 'cats_queue',
    queueOptions: { durable: false },
  },
});
```

> info **힌트** `트랜스포트` 열거자는 `@nestjs/microservices` 패키지에서 가져옵니다.

## Options

트랜스포터 동작을 결정하는 사용 가능한 옵션이 많이 있습니다.

| `urls`                  | Connection urls                                                                                     |
| ----------------------- | --------------------------------------------------------------------------------------------------- |
| `queue`                 | 서버가 청취 할 큐 이름                                                                                       |
| `prefetchCount`         | 채널의 프리 페치 수를 설정합니다                                                                                  |
| `isGlobalPrefetchCount` | 채널당 프리 페치 가능                                                                                        |
| `queueOptions`          | 추가 대기열 옵션. [여기](https://www.squaremobius.net/amqp.node/channel_api.html#assertQueue)에 잘 설명되어 있습니다   |
| `socketOptions`         | 추가 소켓 옵션. [여기](https://www.squaremobius.net/amqp.node/channel_api.html#socket-options)에 잘 설명되어 있습니다 |
