GCP Pub/Sub – 消息过期

huangapple go评论80阅读模式
英文:

GCP Pub/Sub - Message Expiry

问题

根据GCP文档,消息的保留方式如下:

  • 默认情况下,主题在所有附加到该主题的订阅确认消息后立即丢弃消息。主题可以保留已发布的消息最多31天。
  • 默认情况下,Pub/Sub在消息被确认后立即从订阅中丢弃消息。未确认的消息默认保留7天(可配置)。
  • 但是,如果消息所在主题上配置的消息保留持续时间大于7天,则消息可以在订阅中保留超过7天。

问题 - 假设我们有一个单一的订阅者。Pub/Sub主题设置为2天的保留期。在这种情况下,Pub/Sub是否会在消息被读取后将其保留2天,还是立即丢弃并在2天内不可用于回复?对于这句话“默认情况下,Pub/Sub在消息被确认后立即从订阅中丢弃消息”有些困惑。

英文:

As per the GCP documentation, messages are retained as below:

  • By default, a topic discards messages as soon as they are acknowledged by all subscriptions attached to the topic. A topic can retain published messages for a maximum of 31 days
  • By default, Pub/Sub discards a message from a subscription as soon as the message is acknowledged. Unacknowledged messages are retained for a default of 7 days (configurable)
  • However, messages can be retained in a subscription for more than 7 days if the message retention duration configured on its topic is greater than 7 days.

Question - Lets say we have single subscriber. Pub/Sub Topic is set to 2 days retention. In this case, does pub/sub retains message for 2 days after it is being read or discards immediately and not available for reply if needed within 2 days? Little confused with the statement "By default, Pub/Sub discards a message from a subscription as soon as the message is acknowledged".

答案1

得分: 1

保留时间纯粹以发布时间来衡量。因此,保留两天意味着自发布时间起已经过去了两天。如果您想在订阅者确认消息后寻求重新传递消息,则必须满足以下两个条件:

  1. 订阅必须启用保留确认消息,或者主题必须启用消息保留。
  2. 保留时间必须大于消息发布后的时间。

因此,在启用主题保留并设置为两天的情况下,如果消息已经被传递并由订阅者确认,那么在原始发布时间的两天内,可以通过定位来重新传递该消息。

英文:

Retention time is measured purely in terms of publish time. So two days of retention means two days since the time of publish. If you want to seek to redeliver the message after it has been acknowledged by the subscriber, Then two things must be true:

  1. The subscription must have retain ack messages enabled or the topic must have message retention enabled.
  2. The retention time must be greater than the time since the message was published.

So in the case where topic retention is enabled and set to two days, then if the message has been delivered and acknowledged by a subscriber for the subscription, then it is possible to replay the message via a seek within two days of the original publish time.

huangapple
  • 本文由 发表于 2023年7月31日 22:40:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76804686.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定