amqp-node / amqplib

AMQP 0-9-1 library and client for Node.JS
https://amqp-node.github.io/amqplib/
Other
3.7k stars 475 forks source link

x-message-ttl examples #228

Closed molinto closed 8 years ago

molinto commented 8 years ago

Any examples with delayed messages please?

Found this on headers: https://github.com/squaremo/amqp.node/blob/master/examples/headers.js

Good article but its in Ruby: https://www.cloudamqp.com/docs/delayed-messages.html

Thanks

michaelklishin commented 8 years ago

You are confusing optional queue arguments with headers and headers exchanges, which route based on message headers.

See options in Channel#publish: https://github.com/squaremo/amqp.node/blob/master/lib/channel_model.js#L159.

molinto commented 8 years ago

You are correct, I'm totally confused what to do :(

Seen an example here too (but uses https://github.com/postwait/node-amqp): https://bhelx.simst.im/articles/precisely-delaying-jobs-with-dead-letter-exchanges-in-rabbitmq/

cressie176 commented 8 years ago

@molinto Rascal (built on top of amqp.node) can do that for you. See the advanced example. For a bit more context we use the x-message-ttl in combination with the CC routing key field to retry failed messages at 5 minute intervals. If after 10 attempts the message still hasn't succeeded we dead letter.

There's also an experimental plugin for rabbit MQ which does something similar.

molinto commented 8 years ago

Thank you