Google Cloud Functions仅在成功时确认Ack Pub/Sub [英] Google Cloud Functions to only Ack Pub/Sub on success

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

问题描述

我们使用由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.

当我们被呼叫时,云功能似乎正在自动发送ACK Pub/Sub消息.有没有一种方法可以将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?

推荐答案

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

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仅在成功时确认Ack Pub/Sub的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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