Skip to content

Resilience Patterns

frosxt edited this page Jan 20, 2026 · 1 revision

Resilience Patterns

Chronos provides robust mechanisms to handle task failures and network hiccups.

Execution Policy

Define how failures are handled using ExecutionPolicy.

Stop on Failure (Default)

The task enters a FAILED state and will not run again.

ExecutionPolicy.stopOnFailure();

Continue on Failure

The task logs the error (via listeners) and continues to the next scheduled interval.

ExecutionPolicy.continueOnFailure();

Retry with Backoff

Automatically retry a failed task before giving up.

ExecutionPolicy.retry(
    RetryPolicy.exponentialBackoff(
        Duration.ofSeconds(1),  // Initial delay
        Duration.ofMinutes(5),  // Max delay
        2.0,                    // Multiplier
        3                       // Max attempts
    )
);

Jitter

Add randomness to your schedules to prevent "thundering herd" issues when many tasks are scheduled for the same time.

// Add +/- 0 to 500ms
SchedulerSpec.builder()
    .defaultJitter(Jitter.uniform(0.5))
    .build();

Or Gaussian jitter:

// Gaussian distribution (mean 0, stdDev 100ms)
Jitter.gaussian(0.1);

Clone this wiki locally