I have a RabbitMQ queues for documents generation. Basically, each document has type
and state
(new, processing, ready), so I use topic exchange with routing keys like type.state
. Every time document changes I send the message with last document description to the exchange and it works good enough.
However sometimes document can be processed twice:
report.new
is sent to exchange.report.new
for the same document is sent.For now I'm just add small code into workers, comparing last_modified
document key from the message with the one from the database and ack the message if they are not the same. However I don't think this is the best solution.
My idea is to add ID
to message headers and have some RabbitMQ plugin which will remove older messages with the same ID
from the queue.
Thanks.
P.S. Maybe another MQ engine can be useful here? E.g. maybe ActiveMQ has such a feature?
Ok, i've read about RabbitMQ inner architecture and find out it's impossible. So the way around for somebody looking for it.
ID
in message bodyID
value is timestamp of last worker run for this ID
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With