Node.js Nodejs:避免由使用者创建临时rabbitmq队列

Node.js Nodejs:避免由使用者创建临时rabbitmq队列,node.js,rabbitmq,Node.js,Rabbitmq,我使用rabbitmq主题交换来使用从客户端推送的消息。所以我创建了一个队列,并将队列绑定到默认的exchangeamq.topic amqp.connect(uri, (error0, connection) => { if (error0) { throw error0; } connection.createChannel((error1, channel) => { if (error1) { t

我使用rabbitmq
主题交换
来使用从客户端推送的消息。所以我创建了一个队列,并将队列绑定到默认的exchange
amq.topic

amqp.connect(uri, (error0, connection) => {
    if (error0) {
        throw error0;
    }
    connection.createChannel((error1, channel) => {
        if (error1) {
            throw error1;
        }
        channel.assertExchange(exchange, 'topic', {
            durable: true
        });
        channel.assertQueue('', { durable: true });
        channel.bindQueue('queue1', exchange, key);
        try {
            channel.consume('queue1', msg => {
                if (msg !== null) {
                    console.log(" [x] %s:'%s'", msg.fields.routingKey, msg.content.toString());
                }
            }, { noAck: true },);
但是,每次amqp连接并使用消息时,都会创建一个
临时队列
,但不会删除

当我有一个队列时,为什么要创建“消耗时间”中的临时队列?以及如何避免制造新产品


当您试图声明具有空名称的队列时,将生成具有随机名称的队列
amq.gen-*
。这里的问题是您正在传递空白值作为队列名称。将相同内容更改为下面的内容

channel.assertQueue('demo-queue',{dustable:true})


有关更多详细信息,请参见

I已更改为此
channel.assertQueue('queue1',{dustable:true})但我收到错误
错误:服务器关闭的通道:406(Premission-FAILED),消息为“Premission_FAILED-vhost'/'中队列'queue1'的参数'x-queue-type'不等价:未收到任何,但current是'longstr'类型的值'classic'”
@DilvinRiyo您现在正在传递'x-queue-type'参数吗?。如果不需要,请删除它,否则请共享源代码以进一步帮助我。这是我的另一篇文章,其中包含关于发布者和发送者以及如何创建队列和其他@Dilvin Riyo的完整代码