Task Failure

Infinitic is still in active development. Subscribe here to follow the progress.

Any exception occurring during a task execution is seen as a technical issue that

  • is transient and can be fixed by automatic or manual retries,
  • is permanent and needs a fix in the task implementation, followed by a manual retry.

In all cases, don't forget to add a Logger in workers. Otherwise, no error will ever show up.

If you are not sure how to add a Logger, see our Hello World app to see an exemple.

Automatic Retry

When an error occurs during task processing, the task worker will catch it and apply the getDurationBeforeRetry method of the task implementation with the caugth exception to get a java.time.Duration:

  • null means no retry
  • a zero or negative duration triggers an immediate retry
  • a positive duration triggers a delayed retry
public class CarRentalServiceImpl extends Task implements CarRentalService {
    public CarRentalResult book(CarRentalCart cart) {

    public Duration getDurationBeforeRetry(Exception e) {
        int n = context.getRetryIndex();
        if (n < 6) {
            return Duration.ofSeconds((long) (10 * Math.random() * Math.pow(2.0, n)));
        } else {
            return null;
class CarRentalServiceFake: Task(), CarRentalService {
    override fun book(cart: CarRentalCart): CarRentalResult {

    override fun getDurationBeforeRetry(e: Exception): Duration? {
        val n = context.retryIndex
        return when {
            n < 12 -> Duration.ofSeconds((5 * Math.random() * 2.0.pow(n)).toLong())
            else -> null

The exponential backoff strategy illustrated in the getDurationBeforeRetry method above is the actual default implementation of the abstract io.infinitic.tasks.Task. Other policies can be implemented using the task context.

Manual Retry

We can manually retry a task using an Infinitic client.

Manual Cancel

We can manually cancel a task using an Infinitic client.

Edit this page on GitHub Updated at Fri, May 28, 2021