antonyvorontsov / RabbitMQ.Client.Core.DependencyInjection

.Net Core library-wrapper of RabbitMQ.Client for Dependency Injection.
MIT License
111 stars 36 forks source link

Question about connection and channel #87

Closed jerpic closed 3 years ago

jerpic commented 3 years ago

Hello,

Many thanks for your work! It's very helpful and easy to use it.

One question, does your implementation manage itself the connections pooling and channel reuse?

Best Regards, Jérôme.

antonyvorontsov commented 3 years ago

Hi, Jérôme!

If you don't mind, I'll answer relying on the implementation of the library that applies to the 5.0.0 version (and its betas).

Both IProducingService and IConsumingService implementations are registered in a singleton mode. Each of them use separate connections and those connections, obviously, are long lived ones (as the official RabbitMQ documentation advises you to do). Each service (IProducingService and IConsumingService) gets a channel created via "own" connection. And, of course, IConsumingService gets a consumer that is created via its "own" channel.

Basically, two connection and two channels for the lifetime of the application (excluding batch message handlers). So there is no custom pooling algorithms at all.

Default values for connection configuration are

public bool AutomaticRecoveryEnabled { get; set; } = true;

public bool TopologyRecoveryEnabled { get; set; } = true;

public TimeSpan RequestedConnectionTimeout { get; set; } = TimeSpan.FromMilliseconds(60000);

public TimeSpan RequestedHeartbeat { get; set; } = TimeSpan.FromSeconds(60);

and those values are used by the connection factory, so the created connection can manage network problems itself (at least try to).

But maybe I am missing something and do not clearly understand your question.

Best regards, Antony

jerpic commented 3 years ago

Hi Antony,

Thanks for your reply and explanations. Yes, it's totally clear.

Best Regards, Jérôme.