Skip to content

Latest commit

 

History

History
77 lines (51 loc) · 3.63 KB

File metadata and controls

77 lines (51 loc) · 3.63 KB
description
This page provides the technical details of the Retry policy

Retry

Overview

You can use the retry policy to replay requests when experiencing backend connection issues or if the response meets a given condition.

If the retry takes too long, relative to the timeout value, the request stops and returns status code 502.

{% hint style="info" %} To replay a request with a payload, the Gateway stores it in memory. We recommend you avoid applying it to requests with a large payload. {% endhint %}

Functional and implementation information for the retry policy is organized into the following sections:

Examples

{% hint style="warning" %} This policy can only be applied to v2 APIs. It cannot be applied to v4 message APIs or v4 proxy APIs. {% endhint %}

{% tabs %} {% tab title="HTTP proxy API example" %} Sample policy configuration:

{
  "retry": {
    "condition": "{#response.status > 500}",
    "maxRetries": 3,
    "timeout": 1000
  }
}

{% endtab %} {% endtabs %}

Configuration

Phases

The phases checked below are supported by the retry policy:

v2 PhasesCompatible?v4 PhasesCompatible?
onRequesttrueonRequestfalse
onResponsefalseonResponsefalse
onRequestContentfalseonMessageRequestfalse
onResponseContentfalseonMessageResponsefalse

Options

The retry policy can be configured with the following options:

PropertyRequiredDescriptionDefaultExample
conditiontrueCondition to test to determine whether or not to retry the request (supports Expression Language)-{#response.status > 500}
maxRetriestrueNumber of retries before failing (502 - Bad Gateway)1-
delayfalseTime between each attempt0-
timeouttrueTime after which an operation is considered a failure1000-
lastResponsefalseReturns the last attempt response, even if it failed regarding the configured condition. In timeout case, 502 is returned.false-

You can enable or disable the policy with policy identifier retry.

Compatibility matrix

The following is the compatibility matrix for APIM and the retry policy:

Plugin version Supported APIM versions
2.x All

Errors

HTTP status codeReason
502
  • No response satisfies the condition after maxRetries
  • Technical errors when calling the backend (for example, connection refused, timeout)

Changelogs

{% @github-files/github-code-block url="https://github.com/gravitee-io/gravitee-policy-retry/blob/master/CHANGELOG.md" %}