google 云pubsub订阅真的可以自动删除吗?

Can google cloud pubsub subscription really be deleted automatically?

来自文档:

Subscriptions with no activity (push successes or pull requests) for 31 days may be deleted automatically

我需要设置一个推送消息订阅,它的使用率可能非常低(每年几条消息),但对应用程序至关重要。

官方文档上面那句话让我跳了起来! 我应该依赖 google pubsub 还是远离它? 是否有关于此自动机制的更多信息?

需要建议。

是的,订阅会在 Google 云 Pub/Sub 中闲置 31 天后自动删除。如果您每年只发送几条消息,那么听起来 Cloud Pub/Sub 对于您的用例来说可能有点过分了。由于您设置了推送端点,是否可以直接将消息作为 HTTP 请求从您的发布者发送到端点,然后在收到 200 响应时认为它已处理?还是您的推送端点可能在足够长的时间内不可用,以至于您不能依赖它的工作?如此低的吞吐量,您不需要 Pub/Sub 的很多功能,例如流量控制。

如果您坚持使用 Cloud Pub/Sub,您有几个选择:

  1. 从您的发布者发送定期心跳消息以确保订阅未被删除。
  2. 在发布消息之前检查您的订阅是否存在,如有必要,重新创建订阅。

截至 May 16, 2019

的更新答案

Google云Pub/Sub有能力modify subscription expiration policies

To prevent a subscription from expiring, set the expiration period to never.

Pub/Sub 订阅者概述概述了 lifecycle of a subscription:

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.