I am using the package Microsoft.Azure.ServiceBus. Since I should reuse the TopicClient
to get the best use out of AMQP/SBMP, I would be creating it once inside one of my singleton services. However, TopicClient
is not IDisposable
, It only exposes the method CloseAsync
.
What should I do? Do I even need to call this method in my context? The documentation is not really clear about it.
Closes the Client. Closes the connections opened by it.
This is my current draft:
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton(sp => new MyService());
...
public sealed class MyService: IDisposable
public void Dispose()
{
_TopicClient.CloseAsync().GetAwaiter().GetResult();
}
PS: I am only putting messages into the topic, nothing else.