Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * Copyright 2006-2007 the original author or authors.
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.
package org.springframework.batch.retry.backoff;

Implementation of BackOffPolicy that pauses for a fixed period of time before continuing. A pause is implemented using java.lang.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.

Rob Harrop
Dave Syer
public class FixedBackOffPolicy extends StatelessBackOffPolicy {

Default back off period - 1000ms.
	private static final long DEFAULT_BACK_OFF_PERIOD = 1000L;

The back off period in milliseconds. Defaults to 1000ms.
	private volatile long backOffPeriod = ;
	private Sleeper sleeper = new ObjectWaitSleeper();

Public setter for the Sleeper strategy.

sleeper the sleeper to set defaults to ObjectWaitSleeper.
	public void setSleeper(Sleeper sleeper) {
		this. = sleeper;

Set the back off period in milliseconds. Cannot be < 1. Default value is 1000ms.
	public void setBackOffPeriod(long backOffPeriod) {
		this. = (backOffPeriod > 0 ? backOffPeriod : 1);

The backoff period in milliseconds.

the backoff period
	public long getBackOffPeriod() {
		return ;

Pause for the setBackOffPeriod(long).

BackOffInterruptedException if interrupted during sleep.
	protected void doBackOff() throws BackOffInterruptedException {
		try {
		catch (InterruptedException e) {
			throw new BackOffInterruptedException("Thread interrupted while sleeping"e);
New to GrepCode? Check out our FAQ X