public class Replay429Interceptor extends java.lang.Object implements HttpConnectionResponseInterceptor
HttpConnectionResponseInterceptor that retries requests if they
receive a 429 Too Many Requests response. The interceptor will replay the request after a delay
and thereafter continue to replay the request after doubling the delay time for each
subsequent 429 response received up to the maximum number of retries.| Modifier and Type | Field and Description |
|---|---|
static Replay429Interceptor |
WITH_DEFAULTS
Get an instance of a Replay429Interceptor configured with the defaults of 3 retries starting
at a 250 ms backoff and preferring any Retry-After header that may be sent by the server.
|
| Constructor and Description |
|---|
Replay429Interceptor(int numberOfReplays,
long initialBackoff)
Construct a new Replay429Interceptor with a customized number of retries and initial
backoff time.
|
Replay429Interceptor(int numberOfReplays,
long initialBackoff,
boolean preferRetryAfter)
Construct a new Replay429Interceptor with a customized number of retries and initial
backoff time, specifying whether to honour Retry-After headers sent from the server.
|
| Modifier and Type | Method and Description |
|---|---|
HttpConnectionInterceptorContext |
interceptResponse(HttpConnectionInterceptorContext context)
Intercept the response
This method must not do any of the following
Return null
Read the response stream
|
public static final Replay429Interceptor WITH_DEFAULTS
public Replay429Interceptor(int numberOfReplays,
long initialBackoff)
numberOfReplays - number of times to replay a request that received a 429initialBackoff - the initial delay before retryingpublic Replay429Interceptor(int numberOfReplays,
long initialBackoff,
boolean preferRetryAfter)
numberOfReplays - number of times to replay a request that received a 429initialBackoff - the initial delay before retryingpreferRetryAfter - whether the replay should honour the duration specified by a
Retry-After header sent by the server in preference to the local
doubling backoff.public HttpConnectionInterceptorContext interceptResponse(HttpConnectionInterceptorContext context)
HttpConnectionResponseInterceptorinterceptResponse in interface HttpConnectionResponseInterceptorcontext - Input context