How to set MAX_ATTEMPT
of the tasks in google cloud queue in code?
When I create new task, I want to set how many repetitions of a given task should be, can I do it from the code below?
I have google cloud queue like here:
const {CloudTasksClient} = require('@google-cloud/tasks');
const client = new CloudTasksClient();
async function createHttpTask() {
const project = 'my-project-id';
const queue = 'my-queue';
const location = 'us-central1';
const url = 'https://example.com/taskhandler';
const payload = 'Hello, World!';
const inSeconds = 180;
const parent = client.queuePath(project, location, queue);
const task = {
httpRequest: {
httpMethod: 'POST',
url,
},
};
if (payload) {
task.httpRequest.body = Buffer.from(payload).toString('base64');
}
console.log('Sending task:');
console.log(task);
const request = {parent: parent, task: task};
await client.createTask(request);
}
createHttpTask();
From the Google Cloud Documentation i see that I can do it from the console, for the whole queue - https://cloud.google.com/tasks/docs/configuring-queues#retry , but I want to set this dynamically for the tasks
thanks for any help!
Unfortunately, the answer is no. You can not set retry parameters on individual tasks. I make this claim by looking at this document:
REST Resource: projects.locations.queues
which is the REST API for creating task queues. In there, under the documentation for
retryConfig
we read: