0
votes

I am using rabbitmq topic exchange to consume messages that pushed from client. So i created a queue and binded queue to default 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 },);

But every time that amqp connected and consume messages, a Temporary queues created and did not delete ?

Why temporary queues in consume time is created when i have a queue? and how it is possible to avoid from creating?

enter image description here

1

1 Answers

0
votes

Queues with random names amq.gen-* will get generated when you are trying to declare a queue with blank name. Issue here is you are passing blank value as the queue name. Change the same to below.

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

See https://www.rabbitmq.com/tutorials/tutorial-one-javascript.html for more details