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?

有帮助吗?

解决方案

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...

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top