Skip to content

[Bug ]RMQ channel event handlers are added again and again for each send #4044

@ravriel

Description

@ravriel

Describe the bug

In RmqMessageProducer.SendWithDelayAsync event handlers are added for each send and never removed.

            Channel.BasicAcksAsync += OnPublishSucceeded;
            Channel.BasicNacksAsync += OnPublishFailed;

Therefore, for the Nth send the event handler is called N times!
The fix should be to remove the events inside each of the event handlers.

To Reproduce

Set a breakpoint, or add debug print to RmqMessageProducer.OnPublishSucceeded() and RmqMessageProducer.OnPublishFailed()

Use any sample that sends messages to RMQ, for example https://github.com/BrighterCommand/Brighter/blob/master/samples/TaskQueue/RMQTaskQueue/GreetingsSender/Program.cs

Change code to send to the same chnnel multiple times, for example:

            for (var i = 0; i < 10; i++)
            {
                commandProcessor.Post(new GreetingEvent("Ian says: Hi there!"));
                commandProcessor.Post(new FarewellEvent("Ian says: See you later!"));
            }

Verify that the Nth Post triggers the event handler N times!

Further technical details

  • Brighter version: 10.3.0

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions