Ensure reconnect loop in ChannelProvider terminates when disposed
- Fixed #1268
- ChannelProvider now has a CancellationTokenSource that gets cancelled when it is Disposed to ensure any reconnect while loop to be stopped
- CreateConnection will teardown and dispose existing channel if it exists.
During reviewing the code with @danielmarbach we were not sure if 3 is needed.
Also, this PR should be targeting the
masterbranch, not a release branch.
Now targeting master
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.
@danielmarbach @bording do you know if in the mean time any improvements on lifetime management / disposal have been applied to master already?
I don't
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.
Closed in favor of https://github.com/Particular/NServiceBus.RabbitMQ/pull/1435