rabbitmq / rabbitmq-server

Open source RabbitMQ: core server and tier 1 (built-in) plugins
https://www.rabbitmq.com/
Other
12.31k stars 3.92k forks source link

Revival of #9620 Pass the message to `rabbit_backing_queue:discard` callback #12743

Open noxdafox opened 5 days ago

noxdafox commented 5 days ago

Proposed Changes

This is a refresher of PR #9620. It was requested to come back with these changes after HA/Mirroring queues were deprecated.

Here I include the previous PR description:

The rabbit_backing_queue:discard callback is passing the message ID to the implementer. This is often not enough to carry on some necessary work as it's seen in the rabbit_priority_queue comment.

In my particular case, this makes it hard to fix the following issue: https://github.com/noxdafox/rabbitmq-message-deduplication/issues/96

In the above issue a consumer starts consuming with noAck over an empty queue. A publisher publishes a single message which gets forwarded directly to the consumer. In this case, the discard callback is invoked instead of publish_delivered and therefore it's header is not removed from the deduplication cache.

Problem is the discard callback only forwards the message ID and not the whole message not providing enough context for the implementer.

This patch adjust the rabbit_backing_queue behaviour passing the whole message to the discard callback instead of its sole ID.

Types of Changes

What types of changes does your code introduce to this project?

Checklist