Is IAzureClientFactory<ServiceBusClient>.CreateClient() creating a singleton?

35 Views Asked by At

I'm implementing an AzureBusServiceClient and i'm asking if with this configuration below :

enter image description here

And an example of injection:

enter image description here

If i have 3 processors who does "var client = serviceBusClientFactory.CreateClient("Name1");", will i have a new instance each time? Or only one instance is created and retrieved for other calls?

Thank you and sorry for my english :)

Ihave tried for now the singleton approach but i prefer this approach with the factory to handle multiple serviceClientBus.

1

There are 1 best solutions below

1
Jesse Squire On BEST ANSWER

Any registration that uses the builder from AddAzureClients is a singleton, Service Bus included.

For those that are curious about the details, the AddServicebusClient call invokes AzureClientFactoryBuilder.RegisterClientFactory, which manipulates the service collection.