NServiceBus.RabbitMQ icon indicating copy to clipboard operation
NServiceBus.RabbitMQ copied to clipboard

Ensure reconnect loop in ChannelProvider terminates when disposed

Open ramonsmits opened this issue 2 years ago • 4 comments

  • Fixed #1268
  1. ChannelProvider now has a CancellationTokenSource that gets cancelled when it is Disposed to ensure any reconnect while loop to be stopped
  2. CreateConnection will teardown and dispose existing channel if it exists.

During reviewing the code with @danielmarbach we were not sure if 3 is needed.

ramonsmits avatar Jun 22 '23 13:06 ramonsmits

Also, this PR should be targeting the master branch, not a release branch.

Now targeting master

ramonsmits avatar Jul 06 '23 13:07 ramonsmits

There is another reconnection loop that needs to be looked at: The one in the message pump. Has that been examined to see if it would have a similar issue?

Yes, that has been examined by @danielmarbach and that already has cancellation support that will ensure the loop will be terminated:

https://github.com/Particular/NServiceBus.RabbitMQ/blob/aa68a7dbd819453b44bc8fb52e284254fdc06cc8/src/NServiceBus.Transport.RabbitMQ/Receiving/MessagePump.cs#L262-L301

Feels like there are too many changes here that are clouding up the actual fix required, which would be to abort the reconnection loop if the channel provider has been shut down.

You are absolutely right. Removed the "wait for reconnect loop" logic.

ramonsmits avatar Jul 06 '23 14:07 ramonsmits

@danielmarbach @bording do you know if in the mean time any improvements on lifetime management / disposal have been applied to master already?

ramonsmits avatar Feb 28 '24 11:02 ramonsmits

I don't

danielmarbach avatar Feb 28 '24 14:02 danielmarbach

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jul 19 '24 01:07 github-actions[bot]

Closed in favor of https://github.com/Particular/NServiceBus.RabbitMQ/pull/1435

danielmarbach avatar Aug 21 '24 13:08 danielmarbach