【问题标题】:NestJS RabbitMQ set connection nameNestJS RabbitMQ 设置连接名称
【发布时间】:2022-11-27 00:05:27
【问题描述】:

如何使用 NestJS 设置 rabbitMQ 连接名称以便它显示在管理控制台上?我在 RmqOptions 界面中看不到任何选项。

我想像这篇文章中那样为连接设置友好名称: Set connection name with amqplib

我在网上做了一些研究。参考 NestJS 文档并查看代码。

【问题讨论】:

    标签: rabbitmq nestjs


    【解决方案1】:
    this.app.connectMicroservice<MicroserviceOptions>(
          {
            transport: Transport.RMQ,
            options: {
              queue: this.queueName,
              urls: [this.host],
              prefetchCount: 1,
              headers: {
                ['state']: 'initial',
              },
              noAck: false,
              noAssert: true,
              persistent: true,
              queueOptions: {
                durable: false,
                messageTtl: 700,
              } as AmqplibQueueOptions,
              socketOptions: {
                clientProperties: {
                  connection_name: '<NAME_YOUR_CONNECTION_HERE>',
                },
              } as AmqpConnectionManagerSocketOptions,
            },
          },
          { inheritAppConfig: true },
        )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-05
      • 2020-12-20
      • 2021-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多