Google Cloud Functions 仅在成功时确认 Pub/Sub(GCP 解决的问题) [英] Google Cloud Functions to only Ack Pub/Sub on success (Problem resolved by GCP)

查看:21
本文介绍了Google Cloud Functions 仅在成功时确认 Pub/Sub(GCP 解决的问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早期版本的 Google Cloud Functions 在发生错误时的重试方面存在限制.此后,他们提供了解决此问题的增强功能.

An early version of Google Cloud Functions had a limitation with regards to retries when errors occurred. They have since provided enhancements that resolve this issue.

我们正在使用 Pub/Sub 触发的云功能来确保电子邮件的传递.有时电子邮件服务需要很长时间才能响应,而我们的云功能在我们收到错误消息之前就终止了.由于消息已被确认,我们的电子邮件丢失了.

We are using a cloud function triggered by Pub/Sub to ensure delivery of an e-mail. Sometimes the e-mail service takes a long time to respond and our cloud function terminates before we get an error back. Since the message has already been acknowledged our e-mail gets lost.

当我们被调用时,云函数似乎会自动向 Pub/Sub 消息发送 ACK.有没有办法延迟 ACK 直到我们的代码成功完成?或者有没有办法捕捉超时并将消息重新排队以进行传递?还有什么我们可以尝试的吗?

The cloud function appears to be sending an ACK the Pub/Sub message automatically when we are called. Is there a way to delay the ACK until the successful completion of our code? Alternatively is there a way to catch timeouts and requeue the message for delivery? Something else we could try?

推荐答案

这是一个问题,因为函数在调用时确认消息,即使它们崩溃,也会阻止使用新的死信"功能.

This is a problem because Functions ACKing a message on invoke, even if they crash, prevents the use of the new "dead-letter" feature.

此外,它违反了文档.请参阅此代码示例后的注释:https://cloud.google.com/functions/docs/calling/pubsub#sample_code

Also, it goes against the docs. see note after this code sample: https://cloud.google.com/functions/docs/calling/pubsub#sample_code

这篇关于Google Cloud Functions 仅在成功时确认 Pub/Sub(GCP 解决的问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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