Package org.jobrunr.jobs.filters
Class RetryFilter
java.lang.Object
org.jobrunr.jobs.filters.RetryFilter
- All Implemented Interfaces:
ElectStateFilter
,JobFilter
A JobFilter of type
ElectStateFilter
that will retry the job if it fails for up to 10 times with an exponential back-off policy.
This JobFilter is added by default in JobRunr.
If you want to configure the amount of retries, create a new instance and pass it to the JobRunrConfiguration, e.g.:
JobRunr.configure() ... .withJobFilter(new RetryFilter(20, 4)) // this will result in 20 retries and the retries will happen after 4 seconds, 16 seconds, 64 seconds, ... ... .initialize();
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
-
Constructor Summary
ConstructorDescriptionRetryFilter
(int numberOfRetries) RetryFilter
(int numberOfRetries, int backOffPolicyTimeSeed) -
Method Summary
Modifier and TypeMethodDescriptionprotected long
getExponentialBackoffPolicy
(Job job, int seed) protected long
getSecondsToAdd
(Job job) void
onStateElection
(Job job, JobState newState)
-
Field Details
-
DEFAULT_BACKOFF_POLICY_TIME_SEED
public static final int DEFAULT_BACKOFF_POLICY_TIME_SEED- See Also:
-
DEFAULT_NBR_OF_RETRIES
public static final int DEFAULT_NBR_OF_RETRIES- See Also:
-
-
Constructor Details
-
RetryFilter
public RetryFilter() -
RetryFilter
public RetryFilter(int numberOfRetries) -
RetryFilter
public RetryFilter(int numberOfRetries, int backOffPolicyTimeSeed)
-
-
Method Details
-
onStateElection
- Specified by:
onStateElection
in interfaceElectStateFilter
-
getSecondsToAdd
-
getExponentialBackoffPolicy
-