Amqp连接失败时如何接收异常?

时间:2019-10-30 15:18:27

标签: javascript 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_URL是错误的URL时,代码就会卡在waitForConnect()上。

0 个答案:

没有答案
相关问题