EasyNetQ icon indicating copy to clipboard operation
EasyNetQ copied to clipboard

Replacement for IsConnected/ConnectAsync, these methods are misleading

Open Pliner opened this issue 1 year ago • 2 comments

Fixes #1513, Related to #1650, #1433, #1462, #1301, #1147.

There were a lot of complaints for IsConnected behaviour after we added multiple connections under the hood for producer and consumer respectively in #1273. Moreover, laziness of connections made the situation even worse.

I believe that we should remain connections lazy, so providing API to inspect connection status precisely per connection type (instead of global IsConnected property) might reduce awkwardness of the API.

The PR introduces several new methods to IAdvancedBus:

  1. PersistentConnectionStatus GetConnectionStatus(PersistentConnectionType type)
  2. Task EnsureConnectedAsync(PersistentConnectionType type, CancellationToken cancellationToken = default);

EnsureConnectedAsync fixes a small ambiguity of ConnectAsync: ConnectAsync doesn't not throw when a connection was established, but then disrupted.

Pliner avatar Aug 13 '23 13:08 Pliner