I have created a Cloud Task that has a retry policy with max attempts set to (for example 4).
However, we want the Task to fallback to a default solution if the Task fails for the last time.
That is, if the Task fails on the first time we just log the error and return 500. And again for the second time. And the third. Etc... but if the current TaskRetryCount is the last attempt for that queue (i.e. 4 in this example) then we will execute some fallback behaviour before returning 500 for the last time.
I can see from the Cloud Tasks HTTP Handler docs that I can get the X-CloudTasks-TaskRetryCount from the header of the request. But it doesn't seem to have a way to get the max-attempts for the queue.
Is that something that I can get hold of?
Or am I approaching this wrongly? Is there a better way of doing what I'm trying to do.