noxdafox / rabbitmq-message-deduplication

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

How to deduplicate message with routingKey #84

Closed torgashov closed 2 years ago

torgashov commented 2 years ago

Can i use deduplication messages with routingKey? RoutingKey works when i declare exchange with type direct. In your example exchange declaration defined with type x-message-deduplication. Have you any workarounds?

noxdafox commented 2 years ago

Hello,

de-duplication is done based on a dedicated header: x-deduplication-header appended to each message.

A de-duplication exchange is a fanout type of exchange and not a direct one. Hence, the RoutingKey is ignored anyways. You can chain exchanges to each other. In this way, for example, you could obtain what you are looking for.

The first exchange would be of type x-message-deduplication and would deduplicate your messages based on their x-deduplication-header headers. This exchange would then be bound to a direct exchange which would then route the message based on the RoutingKey.

https://www.rabbitmq.com/e2e.html

torgashov commented 2 years ago

Thank you!