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()
上。