PubSub 订阅何时被视为不活动?

When is a PubSub Subscription considered to be inactive?

根据Google Cloud documentation

By default, subscriptions expire after 31 days of inactivity (for instance, if there are no active connections, pull requests, or push successes). If Pub/Sub detects subscriber activity, the subscription deletion clock restarts. Using subscription expiration policies, you can configure the inactivity duration or make the subscription persistent regardless of activity. You can also delete a subscription manually.

即使上面有未确认的消息,订阅是否也被视为无效?

除了documentation you shared, I would like you to pay attention in the following statement, taken from another part part of the documentation,

An unacknowledged message is retained in a subscription for up to message_retention_duration after it is published (the default is 7 days).

因此,向订阅者发布消息后,这些消息将保留7天(default),并开始删除时钟。如果没有更多订阅调用,删除时钟 将继续计算到期时间,因为订阅中不会有任何 activity。另外请注意,7 天后这些未确认的消息将被删除。

是的,如果没有订阅者 activity,订阅将被视为无效,即使该订阅有可用的未确认消息也是如此。

订阅到期是一个可配置的订阅属性,如here所述。