0
votes

Pub Sub topic invokes a cloud function endpoint upon receiving a new message.

If any error happens inside the cloud function the function returns an error.

  1. Whether the delivery will be retried by the PubSub in case of error?
  2. The Cloud function deployed without the retry option. Want to have the retry control on the Pub Sub.

Tried a sample pub sub topic triggered cloud function which always returns the error on execution,

**

import (
    "context"
    "errors"
)
func PushBackOffTest(ctx context.Context, m PubSubMessage) error {
    print(string(m.Data))
    return errors.New("always returns error")
}

**

But the cloud function is not executed again.It ran only once.

ACK deadline 600 seconds. Max delivery attempts 6 . Configured from the G Cloud console.

1

1 Answers

2
votes

If you want the event to be redelivered in the event of an error, then you need to enable retry in your Cloud Function by checking the "Retry on failure" box. Otherwise, Cloud Functions will acknowledge the message received from Pub/Sub regardless of the result of processing it. Checking this box is what tells Cloud Functions to use Cloud Pub/Sub's retry mechanism for unacknowledged messages.