1

I'm running a Cloud Pub/Sub PublisherClient instance as a Singleton in an ASP.NET web application (.NET Standard 2). Does this retain a persistent HTTPS connection to the specified Cloud Pub/Sub Topic and should I call the ShutdownAsync method explicitly, or just let the connection be severed when the app pool recycles?

Running this in conjunction with Quartz.NET, publishing messages to Pub/Sub in relatively small batches, every 30 seconds. This seems to introduce server affinity in a 3-node Azure Load Balancer cluster, where the majority of traffic is routed to any given node after running for 1+ hours. Not 100% sure about best practices here.

Using Pub/Sub C# NuGet package V1 1.0 and Quartz NuGet 3.0.7

Paul Mooney
  • 1,576
  • 12
  • 28

1 Answers1

2

I assume you’re using this PublisherClient. Per the sample documentation, the PublisherClient instance should be shut down after use. This ensures that locally queued messages get sent. See also the ShutdownAsync documentation.

  • Yes, exactly that. The `PublisherClient`runs in the context of a web application, publishing messages throughout the lifetime of the application. Would rather not shutdown after each publish operation if I can help it – Paul Mooney May 02 '19 at 16:07
  • 1
    Can you arrange for `ShutdownAsync` to be called when the application shuts down? – Alex Mordkovich May 02 '19 at 19:02
  • Yes, that's the current implementation. Wondering if it's best practice. Presume it's OK to use `PublisherClient` in a static manner, similar to `HttpClient` – Paul Mooney May 03 '19 at 06:15
  • Is there anything specific about the Pub/Sub SDK, or Quartz.NET that might cause server affinity in a 3-node load-balanced cluster? – Paul Mooney May 03 '19 at 08:38
  • 1
    `Yes, that's the current implementation. Wondering if it's best practice` That seems in line with the documentation. `Is there anything specific about the Pub/Sub SDK, or Quartz.NET that might cause server affinity in a 3-node load-balanced cluster` That seems like another question and requires more background. Feel free to ask it as a new question. – Alex Mordkovich May 03 '19 at 13:36