noxdafox / rabbitmq-message-deduplication

RabbitMQ Plugin for filtering message duplicates
Mozilla Public License 2.0
271 stars 33 forks source link

Queue level message deduplication failed sometimes. #101

Open OliverLiangx opened 1 year ago

OliverLiangx commented 1 year ago

Hello, since I work out on #94, the plugin works fine most of times. But I found out a few message will be consumed twice when we deploy two publisher nodes. So I try to figure out why this happens and it seems to be related to network delay. I wonder if there accessible for queue level to set x-cache-size and x-ttl ? And what is these two config default values?

noxdafox commented 1 year ago

Hello,

the x-cache-size and x-cache-ttl are only used for exchange deduplication.

When you are deduplicating at the queue, you basically want to make sure there will not be 2 copies of the same message within the same queue at the same time. Hence, there is no need to set any TTL for the messages as time is not a relevant matter in here.

The x-cache-ttl is needed for exchange deduplication as we don't know how many messages will pass through an exchange. Hence, the deduplication cache would grow indefinitely. For queues instead, we know how big that cache will be: as big as the queue itself. If you put too many messages in the queue, you will run out of space before the cache size becomes an issue.

This plugin is not intended to handle broker induced duplicates. It works at the application level. In other words, it's designed to catch messages explicitly duplicated by your distributed applications.