Google 云 Pub/Sub 发布者生命周期

Google Cloud Pub/Sub Publisher Lifecycle

我是 运行 云 Pub/Sub PublisherClient 实例,作为 ASP.NET 网络应用程序(.NET 标准 2)中的 Singleton。这是否会保留与指定 Cloud Pub/Sub 主题的持久 HTTPS 连接,我应该显式调用 ShutdownAsync 方法,还是让连接在应用程序池回收时被切断?

运行 这与 Quartz.NET 相结合,以相对较小的批次向 Pub/Sub 发布消息,每 30 秒一次。这似乎在 3 节点 Azure 负载均衡器集群中引入了服务器关联性,其中大部分流量在 运行 后 1 小时以上路由到任何给定节点。不能 100% 确定此处的最佳做法。

使用 Pub/Sub C# NuGet 包 V1 1.0 和 Quartz NuGet 3.0.7

我假设您正在使用 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