I am using firebase functions with pubsub. The functions are invoked every time there is an incoming message (push) I am looking at incorporating retry mechanism for the functions. The retry is not working. The sample function is shown below.
export const helloWorldWithRetry = functions
.runWith({
timeoutSeconds: 300,
memory: "512MB",
vpcConnector: cloudFunctionOptions.connectors["abcd_data_connector"],
vpcConnectorEgressSettings: "ALL_TRAFFIC",
maxInstances: 1,
failurePolicy: {
retry: {},
}
})
.region("asia-south1")
.pubsub.topic("helloWorldPubSubWithRetry")
.onPublish(async (message, context) => {
console.log("----------- ATTEMPTING -------------")
const eventAgeMs = Date.now() - Date.parse(context.timestamp);
console.log(`The event timestamp is ${Date.parse(context.timestamp)} and eventAge is ${eventAgeMs}`)
const eventMaxAgeMs = 60 * 1000;
if (eventAgeMs > eventMaxAgeMs) {
console.log(`Dropping event with age[ms]: ${eventAgeMs}`);
return;
}
throw new Error("Error, Retry")
});
Is there a possibility to use retry in these cases? The documentation says that the message is ack immediately on function invocation
Is putting the message back on queue or pull method the only logical way to achieve retries ?