Possible double delivery/processing of a single message with multiple consumers (C# RabbitMQ.Client 7.1.2, prefetch=1, no redelivery, only one publish) #1847
-
Hello, I am facing a critical and very strange issue with the C# RabbitMQ.Client library (v7.1.2, .NET Framework 4.8, Windows 11, RabbitMQ server 4.0.3 in a container, Erlang 26.2.5.5, Debian 11.11). Problem summary
Code architecture
What has been checked
Sample trace and logs
App logs:
Questions
Thank you for your help and insights! |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 3 replies
-
@sintesfabien no, there are no such known issues. We will not guess as to what might be going on without an executable way to reproduce against a community-supported RabbitMQ version ( Most likely you assume that a certain exchange type, e.g. the direct exchange, can only route a message to one queue even though that's not the case (bind N queues with the same routing key to a direct exchange and it will route the message to N queues). |
Beta Was this translation helpful? Give feedback.
-
No, you are the only user to report this, which makes it very likely the issue is due to how you're using this library. Let me link to my previous comment: #1846 (comment) We are willing to assist you, but only if you make it as easy as possible for us to help you. Right now, you are asking us to guess how to reproduce this issue, which is not something we will do for you. We will need the following: Answers to:
We need a git repository with code to reproduce the issue, as well as the necessary RabbitMQ definitions. We should not have to spend any time getting your code to compile, run, or demonstrate the issue. Clear instructions are required. Again, the simplest and most likely explanation is either your use of this library, or something particular to your environment. |
Beta Was this translation helpful? Give feedback.
-
Hello, |
Beta Was this translation helpful? Give feedback.
-
Hello, This is a new application that has not yet been deployed in production. Best regards |
Beta Was this translation helpful? Give feedback.
-
Thank you for your help. |
Beta Was this translation helpful? Give feedback.
Thank you for your help.
After further investigation, I found that the issue was caused by passing the BasicDeliverEventArgs object (ea) directly to an asynchronous task.
Since this object can be reused or modified by the RabbitMQ client, its content may change between the event handler and the asynchronous processing, leading to message mismatches and unexpected behavior.
This behavior is indeed documented in the RabbitMQ and AMQP client documentation.
Copying the message body and relevant properties immediately in the event handler before starting any asynchronous processing solves the problem.
Thank you again for your guidance and support.