📜  节点关闭rabbitmq连接 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:01:33.729000             🧑  作者: Mango

代码示例1
async sendMsg(msg) {
    const channel = await this.initChannel();

    const sendResult = channel.sendToQueue(this.queue, Buffer.from(msg), {
      persistent: true,
    });

    if (!sendResult) {
      await new Promise((resolve) => channel.once('drain', () => resolve));
    }
  }

  async close() {
    if (this.channel) await this.channel.close();
    await this.conn.close();
  }