Reputation: 146
It seems GCP Cloud Functions always ACK Pubsub PUSH messages when invoked, even if function crashes or fails.
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. Presently, messages never fail.
Is there a way to utilize "dead-letter topic" or pubsub re-delivery with Cloud Functions? Apart for setting the "retry" flag on the function itself, that doesn't solve this issue.
Upvotes: 5
Views: 2225
Reputation: 347
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. 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.
This only solved the problem if the topi has only one subscriber though.
Upvotes: 0
Reputation: 75970
A push subscription impies 2 things:
Here you have created a function in --trigger-topic mode, it's a background function.
You have here what you have to do for marking the function as failed.
Share your code if you need more help
Upvotes: 1