Is it possible to detect if you are in the last processing attempt of an specific task?

StackOverflow https://stackoverflow.com/questions/19439809

  •  01-07-2022
  •  | 
  •  

Question

When using push task queues in Google AppEngine, I know we can use the "X-AppEngine-TaskRetryCount" and "X-AppEngine-TaskExecutionCount" request header parameters to tell how many times we have tried to process an specific task. Is it possible to detect if it's the last attempt or not?

Était-ce utile?

La solution

A workaround is to pass the max retry count as a parameter in the HTTP request when you add tasks to TaskQueue. Then, you can detect if is the last attempt comparing the header attribute "X-AppEngine-TaskRetryCount" with your custom param:

Boolean isLastAttempt = (taskRetryCount == (maxRetryCount - 1));

Not exactly a good design approach though...

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top