0

I have a ASP.NET Core API that talks to an Azure ServiceBus through the QueueClient class.

The IQueueClient interface is registered as a singleton in the DI (new'ing it up once such as: new QueueClient(...). This is one of the approach in Microsofts recommended ways of talking to a SericeBus. We could use a MessageFactory too, but I don't think it matters for the question I have.

For monitoring purposes, i'd like to check the health of the service bus (or the service bus connection at least). I found that you can use queueClient.IsClosedOrClosing, but you can also use queueClient.ServiceBusConnection.IsClosedOrClosing. One checks the queueClient's connection to the service bus (?), and the other one... too?

What's the difference here?

Thanks for your help!

Jim Aho
  • 9,932
  • 15
  • 56
  • 87

1 Answers1

3

Both queueClient.IsClosedOrClosing and  queueClient.ServiceBusConnection.IsClosedOrClosing are the same. Any client, queue, topic, or subscription has and maintains a connection to the broker. This connection was either passed into the client at the time of construction or is created by the client when a connection string is given to the constructor. Since connection object is exposed on the clients, you get the access to the IsClosedOrClosing property in two ways.

Jim Aho
  • 9,932
  • 15
  • 56
  • 87
Sean Feldman
  • 23,443
  • 7
  • 55
  • 80