Hi there!
I wasn't sure if I should create an issue on GitHub or post here, I've posted here to be on the safe side as this is a discussion at the moment.
In the move from v5.0.0 to v6.0.0 of the .NET client,
IAutoRecoveringConnection was created to hold connection recovery events in
https://github.com/rabbitmq/rabbitmq-dotnet-client/pull/758. However it isn't possible to get hold of one via the public API, as
ConnectionFactory.CreateConnection() returns an
IConnection.
Is it worth considering a change to the public API to allow for returning an IAutoRecoveringConnection? I can see two ways to do this:
- Non breaking: create another method ConnectionFactory.CreateAutoRecoveringConnection() which returns an IAutoRecoveringConnection. This would ignore whatever value ConnectionFactory.AutomaticRecoveryEnabled is set to, however this could be confusing to API users.
- Breaking: Remove ConnectionFactory.AutomaticRecoveryEnabled and have ConnectionFactory.CreateConnection() create a Connection and return an IConnection, and add ConnectionFactory.CreateAutoRecoveringConnection() which creates an AutoRecoveringConnection and returns an IAutoRecoveringConnection.
I'm not sure what would be preferred. Of course there may be a better solution that I haven't thought of.
At the moment we can work around this by checking if our IConnection object is actually an IRecoveringConnection casting it and subscribing to the events, but I think it would be better to provide a proper way of getting an IRecoveringConnection.
Hopefully my rambling has made sense! Please let me know if I should post this on GitHub instead.
Many thanks,
Alex