Here’s a demonstration of how to set the retry options on a task. The following code configures a task to retry 3 times (if the initial request fails) and to double the time between retries at most twice.
//Configures the retry options for the task.
//Here we're saying to retry 3 times if the task initially
//fails, and to increase the time between retries.
RetryOptions retry = RetryOptions.Builder.withTaskRetryLimit(3);
retry.maxDoublings(2);
The following line sets the options onto a task ( task represents a TaskOptions object ):
task.retryOptions(retry);
Remember to import the RetryOptions class:
import com.google.appengine.api.taskqueue.RetryOptions;