-
Notifications
You must be signed in to change notification settings - Fork 0
Resilience Patterns
frosxt edited this page Jan 20, 2026
·
1 revision
Chronos provides robust mechanisms to handle task failures and network hiccups.
Define how failures are handled using ExecutionPolicy.
The task enters a FAILED state and will not run again.
ExecutionPolicy.stopOnFailure();The task logs the error (via listeners) and continues to the next scheduled interval.
ExecutionPolicy.continueOnFailure();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
)
);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);