首页 > 解决方案 > Amqp无法连接时如何接收异常?

问题描述

const amqp = require('amqp-connection-manager')

const {CONNECTION_URL} = require('./config/env')

class AmqpConnectionService {

  async openConnection() {
    this.connection = await amqp.connect([CONNECTION_URL])
    this.channelWrapper = await this.connection.createChannel({setup(channel) {}})

    await this.channelWrapper.waitForConnect()
  }

使用此代码,当CONNECTION_URLURL 错误时,代码会卡在waitForConnect().

标签: javascriptamqp

解决方案


推荐阅读