Google云端发布/子重试次数 [英] Google Cloud Pub/Sub Retry Count

查看:159
本文介绍了Google云端发布/子重试次数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在从一个不稳定的消息队列服务转移到NodeJS中的Google Pub Sub。它似乎工作正常,但我们想包括错误处理。

我们想限制特定消息的重试次数,例如在我们的测试环境中10次生产100次。现在,如果一条消息失败了10次(测试中),而不是它坐在我们的队列中,并继续处理并失败7天,我们希望将其移至单独的错误队列并发送给我们一封电子邮件。



我们现在已将所有这些设置在我们以前的消息队列中,但我们尚未找到Google的每个消息的Pub Sub重试计数属性。有谁知道这是否存在?



我们在Google App Engine中使用任务队列,他们拥有我们需要的所有东西,但Google的pub子似乎缺少很多。我们确实需要任何解决方案在Node中。

解决方案

Cloud Pub / Sub对其次数没有限制将重试向用户传送消息。如果您的用户从不在确认期限内确认该消息,它将被重新发送,直到消息7天后过期。



如果你想停止接收这些消息,那么你需要在某个时候确认它们。如果您想防止订阅者无法处理的死亡信息,我建议您采取以下措施:


  1. 保留消息失败的跟踪数在数据库中,由消息ID键入。希望失败不是很频繁,所以这个数据库不应该太大,只有在实际失败时才会对它进行查询。

  2. 当一个消息失败,查询数据库并查看之前发生了多少次故障。如果计数低于阈值,则不要确认消息。 如果消息的失败次数超过阈值,请将消息发布到单独的失败的消息主题,发送电子邮件,并确认消息。 如果有必要,有办法发布失败的消息主题回到您的主要话题,当首先导致信息失败的问题得到解决。


您现在将邮件保存在单独的主题中(7天或直到您确认邮件),邮件将不会重新发送给主题上的订阅者。


We are moving from an unstable messaging queue service to Google's Pub Sub in NodeJS. It seems to work well but we would like to include error handling.

We would like to limit the number of retries for a particular message, say 10 times in our test environment and 100 times in production. Now if a message fails 10 times (in test), instead of it sitting in our queue and continue to be processed and fail for 7 days we would like to move it to a separate error queue and send us an email.

We currently have all of this set up in our previous messaging queue but we have yet to find Google's Pub Sub retry count attribute for each message. Does anyone know if this exists?

We do use task queues in Google App Engine and they have everything we would need but Google's pub sub seems to be missing a lot. We do require any solution to be in Node.

解决方案

Cloud Pub/Sub does not have a limit to the number of times it will retry delivery of a message to a subscriber. If your subscriber never acknowledges the message within the ack deadline, it will be redelivered until the message expires 7 days later.

If you want to stop receiving these messages, then you will need to ack them at some point. If you want to protect against "messages of death" that cannot be processed by your subscribers, I recommend the following:

  1. Keep track of message failure counts in a database, keyed by message id. Hopefully, failures are not frequent, so this database should not be too large and queries to it will only be made when there is actually a failure.

  2. When a message fails, query the database and see how many failures have occurred before. Increment the counter and do not acknowledge the message if the count is below your threshold.

  3. If a message fails more times than your threshold, publish the message to a separate "failed messages" topic, send an email, and acknowledge the message.

  4. If necessary, have a means by which to publish messages from the "failed messages" topic back to your main topic when the problems that caused the message to fail in the first place have been remedied.

You now have the message saved in a separate topic (for 7 days or until you ack it) and the message won't be redelivered to the subscribers on your main topic.

这篇关于Google云端发布/子重试次数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆