org.springframework.retry.backoff
Class FixedBackOffPolicy

java.lang.Object
  extended by org.springframework.retry.backoff.StatelessBackOffPolicy
      extended by 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 Thread.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

Constructor Summary
FixedBackOffPolicy()
           
 
Method Summary
protected  void doBackOff()
          Pause for the setBackOffPeriod(long).
 long getBackOffPeriod()
          The backoff period in milliseconds.
 void setBackOffPeriod(long backOffPeriod)
          Set the back off period in milliseconds.
 void setSleeper(Sleeper sleeper)
          Public setter for the Sleeper strategy.
 java.lang.String toString()
           
 FixedBackOffPolicy 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 Detail

FixedBackOffPolicy

public FixedBackOffPolicy()
Method Detail

withSleeper

public FixedBackOffPolicy withSleeper(Sleeper sleeper)
Description copied from interface: SleepingBackOffPolicy
Clone the policy and return a new policy which uses the passed sleeper.

Specified by:
withSleeper in interface SleepingBackOffPolicy<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 void setSleeper(Sleeper sleeper)
Public setter for the Sleeper strategy.

Parameters:
sleeper - the sleeper to set defaults to ObjectWaitSleeper.

setBackOffPeriod

public void setBackOffPeriod(long backOffPeriod)
Set the back off period in milliseconds. Cannot be < 1. Default value is 1000ms.


getBackOffPeriod

public long getBackOffPeriod()
The backoff period in milliseconds.

Returns:
the backoff period

doBackOff

protected void doBackOff()
                  throws BackOffInterruptedException
Pause for the setBackOffPeriod(long).

Specified by:
doBackOff in class StatelessBackOffPolicy
Throws:
BackOffInterruptedException - if interrupted during sleep.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2013 SpringSource. All Rights Reserved.