This is my code:
const amqp = require('amqplib');
amqp.connect().then((conn) => {
var ok = conn.createChannel();
ok = ok.then((ch) => {
ch.assertQueue('myFirstQueue', {
arguments: {
messageTtl: 1000
}
})
.then(response => {
let q = response;
let msg = 'hello';
let message = new Buffer(JSON.stringify(msg).toString('base64'));
ch.sendToQueue(q.queue, message);
return ok;
})
.catch(error => {
return error;
})
});
});
What I expect is that the message expires in a second. When I run my consumer in a few seconds, the message arrives!
Reading the documentation, I understand that I simply have to add arguments in options and pass messageTtl
in miliseconds.
What I'm doing wrong?