Search code examples
node.jsrabbitmqamqpttl

How to use x-message-ttl in node-amqp?


How to set x-message-ttl for queue RabbitMQ? I use node-amqp package.

connection.queue('echo', {autoDelete: false, durable: true, "x-message-ttl":20000});


Solution

  • x-message-ttl is an argument. Arguments are passed under arguments options property, so something like

    connection.queue('echo', {
        autoDelete : false,
        durable    : true,
        arguments  : {
            "x-message-ttl" : 20000
        }
    });
    

    should do the job.

    For more details see queue.js source code and queue.declare AMQP method documentation