[英]Google Cloud Functions can't use Pub/Sub dead-letter topic
It seems GCP Cloud Functions always ACK Pubsub PUSH messages when invoked, even if function crashes or fails.似乎 GCP Cloud Functions 在调用时总是 ACK Pubsub PUSH 消息,即使 function 崩溃或失败。
This prevents the use of the new Pub/Sub "dead-letter" topic feature, which required message delivery to fail before forwarding it to a different topic.这可以防止使用新的 Pub/Sub“死信”主题功能,该功能需要消息传递失败,然后才能将其转发到不同的主题。 Presently, messages never fail.
目前,消息永远不会失败。
Is there a way to utilize "dead-letter topic" or pubsub re-delivery with Cloud Functions?有没有办法利用 Cloud Functions 的“死信主题”或 pubsub 重新交付? Apart for setting the "retry" flag on the function itself, that doesn't solve this issue.
除了在 function 本身上设置“重试”标志外,这并不能解决这个问题。
A push subscription impies 2 things:推送订阅意味着两件事:
Here you have created a function in --trigger-topic mode, it's a background function.在这里,您在 --trigger-topic 模式下创建了一个 function,它是一个背景 function。
You have here what you have to do for marking the function as failed .您在这里可以将 function 标记为 failed 。
Share your code if you need more help如果您需要更多帮助,请分享您的代码
One way that this can be handled (until GCP starts supporting manual acknowledgement for cloud function) is by re-queueing to the same topic with the retry count incremented in case of failure.可以处理这种情况的一种方法(直到 GCP 开始支持云功能的手动确认)是通过重新排队到相同的主题,并在失败的情况下增加重试计数。 You can store the retry counts in the payload itself like:
您可以将重试计数存储在有效负载本身中,例如:
{
"retry_count": 1,
"data": {...}
}
Also to avoid the a faulty message being retried permanently, you can configure it to push to the dead-letter instead if the retry attempts > x.此外,为了避免错误消息被永久重试,您可以将其配置为在重试尝试 > x 时推送到死信。
This only solved the problem if the topi has only one subscriber though.这仅在 topi 只有一个订阅者的情况下才解决了问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.