Class FixedBackOffPolicy
java.lang.Object
org.springframework.retry.backoff.StatelessBackOffPolicy
org.springframework.retry.backoff.FixedBackOffPolicy
- All Implemented Interfaces:
BackOffPolicy
,SleepingBackOffPolicy<FixedBackOffPolicy>
public class FixedBackOffPolicy
extends StatelessBackOffPolicy
implements SleepingBackOffPolicy<FixedBackOffPolicy>
Implementation of
BackOffPolicy
that pauses for a fixed period of time before
continuing. A pause is implemented using Sleeper.sleep(long)
.
setBackOffPeriod(long)
is thread-safe and it is safe to call
setBackOffPeriod(long)
during execution from multiple threads, however this may
cause a single retry operation to have pauses of different intervals.- Author:
- Rob Harrop, Dave Syer, Artem Bilan, Marius Lichtblau
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
backOffPeriodSupplier
(Supplier<Long> backOffPeriodSupplier) Set a supplier for the back off period in milliseconds.protected void
Pause for thesetBackOffPeriod(long)
.long
The backoff period in milliseconds.void
setBackOffPeriod
(long backOffPeriod) Set the back off period in milliseconds.void
setSleeper
(Sleeper sleeper) Public setter for theSleeper
strategy.toString()
withSleeper
(Sleeper sleeper) Clone the policy and return a new policy which uses the passed sleeper.Methods inherited from class org.springframework.retry.backoff.StatelessBackOffPolicy
backOff, start
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.retry.backoff.BackOffPolicy
backOff, start
-
Constructor Details
-
FixedBackOffPolicy
public FixedBackOffPolicy()
-
-
Method Details
-
withSleeper
Description copied from interface:SleepingBackOffPolicy
Clone the policy and return a new policy which uses the passed sleeper.- Specified by:
withSleeper
in interfaceSleepingBackOffPolicy<FixedBackOffPolicy>
- Parameters:
sleeper
- Target to be invoked any time the backoff policy sleeps- Returns:
- a clone of this policy which will have all of its backoff sleeps routed into the passed sleeper
-
setSleeper
Public setter for theSleeper
strategy.- Parameters:
sleeper
- the sleeper to set defaults toThreadWaitSleeper
.
-
setBackOffPeriod
public void setBackOffPeriod(long backOffPeriod) Set the back off period in milliseconds. Cannot be < 1. Default value is 1000ms.- Parameters:
backOffPeriod
- the back off period
-
backOffPeriodSupplier
Set a supplier for the back off period in milliseconds. Cannot be < 1. Default supplier supplies 1000ms.- Parameters:
backOffPeriodSupplier
- the back off period- Since:
- 2.0
-
getBackOffPeriod
public long getBackOffPeriod()The backoff period in milliseconds.- Returns:
- the backoff period
-
doBackOff
Pause for thesetBackOffPeriod(long)
.- Specified by:
doBackOff
in classStatelessBackOffPolicy
- Throws:
BackOffInterruptedException
- if interrupted during sleep.
-
toString
-