AMQP Delivery Delay and Message Duplication Prevention

I have a system that will generate messages sporadically, and I would like to send only zero or one message every 5 minutes. If a message is not generated, nothing will be processed by the queue consumer. If within 5 minutes a hundred identical messages are generated, I want one of them to be used up from the queue.

I am using AMQP (RabbitMQ), is there a way to do this using rabbitmq or the AMQP protocol? Can I check the contents of the queue to make sure that I am not inserting a duplicate? Queuing seems to be a bad idea, and usually this should not be done for the messaging system.

Without checking the queue, can this be done using these tools? The only solution that comes to mind is the second line, which receives all messages, then the consumer reads each message and puts it in the internal queue, waits 5 minutes, and any repeated messages are discarded. After the delay, one message is placed in the "real" queue to be processed.

It looks like this might be a normal situation that the queue system can handle. Any ideas?

+3
process duplicate-removal delay message-queue amqp
source share
1 answer

Handling the state of a message is not something AMQP deals with. You can try to process the state in some process that is also present in AMQ and proxy messages (as you wrote in the original question). Depending on your situation, you might be able to use strings or more sophisticated means of detecting a double number without saving the state, but AMQP does not handle this particular use case.

The only thing guaranteed is that if multiple bindings correspond to a message, which is then delivered to the queue, in fact only one message is sent.

+2
source share

All Articles