Files
spring-batch/build/reference-epub-work/ch09s03.xhtml
Michael Minella 75ab909314 update
2017-03-23 10:18:33 -05:00

19 lines
2.0 KiB
HTML

<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg"><head><title>Backoff Policies</title><link rel="stylesheet" type="text/css" href="docbook-epub.css"/><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"/><link rel="prev" href="ch09s02.xhtml" title="Retry Policies"/><link rel="next" href="ch09s04.xhtml" title="Listeners"/></head><body><header/><section class="section" title="Backoff Policies" epub:type="subchapter" id="backoffPolicies"><div class="titlepage"><div><div><h2 class="title" style="clear: both">Backoff Policies</h2></div></div></div><p>When retrying after a transient failure it often helps to wait a bit
before trying again, because usually the failure is caused by some problem
that will only be resolved by waiting. If a
<code class="classname">RetryCallback</code> fails, the
<code class="classname">RetryTemplate</code> can pause execution according to the
<code class="classname">BackoffPolicy</code> in place.</p><pre class="programlisting">public interface BackoffPolicy {
BackOffContext start(RetryContext context);
void backOff(BackOffContext backOffContext)
throws BackOffInterruptedException;
}</pre><p>A <code class="classname">BackoffPolicy</code> is free to implement
the backOff in any way it chooses. The policies provided by Spring Batch
out of the box all use <code class="code">Object.wait()</code>. A common use case is to
backoff with an exponentially increasing wait period, to avoid two retries
getting into lock step and both failing - this is a lesson learned from
the ethernet. For this purpose Spring Batch provides the
<code class="classname">ExponentialBackoffPolicy</code>.</p></section><footer/></body></html>