微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

兔子MQ在 Amazon MQ 中找不到队列 (404)

如何解决兔子MQ在 Amazon MQ 中找不到队列 (404)

使用 Typescript 3.9.7amqplib 0.6.0。今天在 Amazon MQ 中创建新的代理。但是当我尝试连接到 Rabbit 并断言交换和队列时,我看到了这个错误

Channel closed by server: 404 (NOT-FOUND) with message "NOT_FOUND - no queue 'QUEUE-NAME' in vhost '/'"

这是代码

const rabbitMQParams: { connection: amqplib.Connection | null } = {
    connection: null,};

const connectRabbitMq = async () => {
        const options: amqplib.Options.Connect = { protocol,hostname: host,port: +port!,username: user,password }; 
    // protocol and other variables are correct
        rabbitMQParams.connection = await amqplib.connect(options); 
}

const setConnectionAndChannel = async (job: WorkTypes) => {
        if (!rabbitMQParams.connection) {
            await connectRabbitMq();
        }
        if (!this.channel) {
            this.channel = await rabbitMQParams.connection!.createChannel();
        }

        const isExchangeExists: Replies.Empty = await this.channel.checkExchange(WorkQueueHelper.exchange);
        if (!isExchangeExists) {
            await this.channel.assertExchange(WorkQueueHelper.exchange,'direct',{ durable: durableExchanges });
        }
        const queueName: string = 'QUEUE-NAME';
        const isQueueExists: Replies.Empty = await this.channel.checkQueue(queueName)
        if (!isQueueExists) {
            await this.channel.assertQueue(queueName,{ durable: durableQueues,autoDelete: false });
        }
        await this.channel.bindQueue(queueName,WorkQueueHelper.exchange,job);
    }

网上没有找到什么好的教程来避免这个错误。请帮帮我

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。