azure-docs-sdk-java/docs-ref-autogen/com.azure.core.http.policy....

121 строка
16 KiB
YAML

### YamlMime:JavaType
uid: "com.azure.core.http.policy.RetryPolicy"
fullName: "com.azure.core.http.policy.RetryPolicy"
name: "RetryPolicy"
nameWithType: "RetryPolicy"
summary: "The `RetryPolicy` class is an implementation of the <xref uid=\"com.azure.core.http.policy.HttpPipelinePolicy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"HttpPipelinePolicy\"></xref> interface."
inheritances:
- "<xref href=\"java.lang.Object?displayProperty=fullName\" data-throw-if-not-resolved=\"False\" />"
inheritedClassMethods:
- classRef: "java.lang.<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html\">Object</a>"
methodsRef:
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--\">clone</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-\">equals</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--\">finalize</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--\">getClass</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--\">hashCode</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--\">notify</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--\">notifyAll</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--\">toString</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--\">wait</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-\">wait</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-\">wait</a>"
syntax: "public class **RetryPolicy**</br> implements <xref href=\"com.azure.core.http.policy.HttpPipelinePolicy?alt=com.azure.core.http.policy.HttpPipelinePolicy&text=HttpPipelinePolicy\" data-throw-if-not-resolved=\"False\" />"
constructors:
- uid: "com.azure.core.http.policy.RetryPolicy.RetryPolicy()"
fullName: "com.azure.core.http.policy.RetryPolicy.RetryPolicy()"
name: "RetryPolicy()"
nameWithType: "RetryPolicy.RetryPolicy()"
summary: "Creates <xref uid=\"com.azure.core.http.policy.RetryPolicy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryPolicy\"></xref> using <xref uid=\"com.azure.core.http.policy.ExponentialBackoff.ExponentialBackoff()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ExponentialBackoff#ExponentialBackoff()\"></xref> as the <xref uid=\"com.azure.core.http.policy.RetryStrategy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryStrategy\"></xref>."
syntax: "public RetryPolicy()"
desc: "Creates <xref uid=\"com.azure.core.http.policy.RetryPolicy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryPolicy\"></xref> using <xref uid=\"com.azure.core.http.policy.ExponentialBackoff.ExponentialBackoff()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ExponentialBackoff#ExponentialBackoff()\"></xref> as the <xref uid=\"com.azure.core.http.policy.RetryStrategy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryStrategy\"></xref>."
- uid: "com.azure.core.http.policy.RetryPolicy.RetryPolicy(com.azure.core.http.policy.RetryOptions)"
fullName: "com.azure.core.http.policy.RetryPolicy.RetryPolicy(RetryOptions retryOptions)"
name: "RetryPolicy(RetryOptions retryOptions)"
nameWithType: "RetryPolicy.RetryPolicy(RetryOptions retryOptions)"
summary: "Creates a <xref uid=\"com.azure.core.http.policy.RetryPolicy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryPolicy\"></xref> with the provided <xref uid=\"com.azure.core.http.policy.RetryOptions\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryOptions\"></xref>."
parameters:
- description: "The <xref uid=\"com.azure.core.http.policy.RetryOptions\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryOptions\"></xref> used to configure this <xref uid=\"com.azure.core.http.policy.RetryPolicy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryPolicy\"></xref>."
name: "retryOptions"
type: "<xref href=\"com.azure.core.http.policy.RetryOptions?alt=com.azure.core.http.policy.RetryOptions&text=RetryOptions\" data-throw-if-not-resolved=\"False\" />"
syntax: "public RetryPolicy(RetryOptions retryOptions)"
desc: "Creates a <xref uid=\"com.azure.core.http.policy.RetryPolicy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryPolicy\"></xref> with the provided <xref uid=\"com.azure.core.http.policy.RetryOptions\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryOptions\"></xref>."
- uid: "com.azure.core.http.policy.RetryPolicy.RetryPolicy(com.azure.core.http.policy.RetryStrategy)"
fullName: "com.azure.core.http.policy.RetryPolicy.RetryPolicy(RetryStrategy retryStrategy)"
name: "RetryPolicy(RetryStrategy retryStrategy)"
nameWithType: "RetryPolicy.RetryPolicy(RetryStrategy retryStrategy)"
summary: "Creates a <xref uid=\"com.azure.core.http.policy.RetryPolicy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryPolicy\"></xref> with the provided <xref uid=\"com.azure.core.http.policy.RetryStrategy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryStrategy\"></xref>."
parameters:
- description: "The <xref uid=\"com.azure.core.http.policy.RetryStrategy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryStrategy\"></xref> used for retries."
name: "retryStrategy"
type: "<xref href=\"com.azure.core.http.policy.RetryStrategy?alt=com.azure.core.http.policy.RetryStrategy&text=RetryStrategy\" data-throw-if-not-resolved=\"False\" />"
syntax: "public RetryPolicy(RetryStrategy retryStrategy)"
desc: "Creates a <xref uid=\"com.azure.core.http.policy.RetryPolicy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryPolicy\"></xref> with the provided <xref uid=\"com.azure.core.http.policy.RetryStrategy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryStrategy\"></xref>."
- uid: "com.azure.core.http.policy.RetryPolicy.RetryPolicy(com.azure.core.http.policy.RetryStrategy,java.lang.String,java.time.temporal.ChronoUnit)"
fullName: "com.azure.core.http.policy.RetryPolicy.RetryPolicy(RetryStrategy retryStrategy, String retryAfterHeader, ChronoUnit retryAfterTimeUnit)"
name: "RetryPolicy(RetryStrategy retryStrategy, String retryAfterHeader, ChronoUnit retryAfterTimeUnit)"
nameWithType: "RetryPolicy.RetryPolicy(RetryStrategy retryStrategy, String retryAfterHeader, ChronoUnit retryAfterTimeUnit)"
summary: "Creates <xref uid=\"com.azure.core.http.policy.RetryPolicy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryPolicy\"></xref> with the provided <xref uid=\"com.azure.core.http.policy.RetryStrategy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryStrategy\"></xref> and default <xref uid=\"com.azure.core.http.policy.ExponentialBackoff\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ExponentialBackoff\"></xref> as <xref uid=\"com.azure.core.http.policy.RetryStrategy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryStrategy\"></xref>."
parameters:
- description: "The <xref uid=\"com.azure.core.http.policy.RetryStrategy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryStrategy\"></xref> used for retries."
name: "retryStrategy"
type: "<xref href=\"com.azure.core.http.policy.RetryStrategy?alt=com.azure.core.http.policy.RetryStrategy&text=RetryStrategy\" data-throw-if-not-resolved=\"False\" />"
- description: "The HTTP header, such as 'Retry-After' or 'x-ms-retry-after-ms', to lookup for the retry\n delay. If the value is null, <xref uid=\"com.azure.core.http.policy.RetryPolicy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryPolicy\"></xref> will use the retry strategy to compute the delay and ignore the\n delay provided in response header."
name: "retryAfterHeader"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "The time unit to use when applying the retry delay. null is valid if, and only if,\n <code>retryAfterHeader</code> is null."
name: "retryAfterTimeUnit"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/time/temporal/ChronoUnit.html\">ChronoUnit</a>"
syntax: "public RetryPolicy(RetryStrategy retryStrategy, String retryAfterHeader, ChronoUnit retryAfterTimeUnit)"
desc: "Creates <xref uid=\"com.azure.core.http.policy.RetryPolicy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryPolicy\"></xref> with the provided <xref uid=\"com.azure.core.http.policy.RetryStrategy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryStrategy\"></xref> and default <xref uid=\"com.azure.core.http.policy.ExponentialBackoff\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ExponentialBackoff\"></xref> as <xref uid=\"com.azure.core.http.policy.RetryStrategy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryStrategy\"></xref>. It will use provided `retryAfterHeader` in <xref uid=\"com.azure.core.http.HttpResponse\" data-throw-if-not-resolved=\"false\" data-raw-source=\"HttpResponse\"></xref> headers for calculating retry delay."
- uid: "com.azure.core.http.policy.RetryPolicy.RetryPolicy(java.lang.String,java.time.temporal.ChronoUnit)"
fullName: "com.azure.core.http.policy.RetryPolicy.RetryPolicy(String retryAfterHeader, ChronoUnit retryAfterTimeUnit)"
name: "RetryPolicy(String retryAfterHeader, ChronoUnit retryAfterTimeUnit)"
nameWithType: "RetryPolicy.RetryPolicy(String retryAfterHeader, ChronoUnit retryAfterTimeUnit)"
summary: "Creates <xref uid=\"com.azure.core.http.policy.RetryPolicy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryPolicy\"></xref> using <xref uid=\"com.azure.core.http.policy.ExponentialBackoff.ExponentialBackoff()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ExponentialBackoff#ExponentialBackoff()\"></xref> as the <xref uid=\"com.azure.core.http.policy.RetryStrategy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryStrategy\"></xref> and uses `retryAfterHeader` to look up the wait period in the returned <xref uid=\"com.azure.core.http.HttpResponse\" data-throw-if-not-resolved=\"false\" data-raw-source=\"HttpResponse\"></xref> to calculate the retry delay when a recoverable HTTP error is returned."
parameters:
- description: "The HTTP header, such as <code>Retry-After</code> or <code>x-ms-retry-after-ms</code>, to lookup\n for the retry delay. If the value is null, <xref uid=\"com.azure.core.http.policy.RetryStrategy.calculateRetryDelay(int)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryStrategy#calculateRetryDelay(int)\"></xref> will compute the delay\n and ignore the delay provided in response header."
name: "retryAfterHeader"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "The time unit to use when applying the retry delay. Null is valid if, and only if,\n <code>retryAfterHeader</code> is null."
name: "retryAfterTimeUnit"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/time/temporal/ChronoUnit.html\">ChronoUnit</a>"
syntax: "public RetryPolicy(String retryAfterHeader, ChronoUnit retryAfterTimeUnit)"
desc: "Creates <xref uid=\"com.azure.core.http.policy.RetryPolicy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryPolicy\"></xref> using <xref uid=\"com.azure.core.http.policy.ExponentialBackoff.ExponentialBackoff()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ExponentialBackoff#ExponentialBackoff()\"></xref> as the <xref uid=\"com.azure.core.http.policy.RetryStrategy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryStrategy\"></xref> and uses `retryAfterHeader` to look up the wait period in the returned <xref uid=\"com.azure.core.http.HttpResponse\" data-throw-if-not-resolved=\"false\" data-raw-source=\"HttpResponse\"></xref> to calculate the retry delay when a recoverable HTTP error is returned."
methods:
- uid: "com.azure.core.http.policy.RetryPolicy.process(com.azure.core.http.HttpPipelineCallContext,com.azure.core.http.HttpPipelineNextPolicy)"
fullName: "com.azure.core.http.policy.RetryPolicy.process(HttpPipelineCallContext context, HttpPipelineNextPolicy next)"
name: "process(HttpPipelineCallContext context, HttpPipelineNextPolicy next)"
nameWithType: "RetryPolicy.process(HttpPipelineCallContext context, HttpPipelineNextPolicy next)"
summary: "Processes provided request context and invokes the next policy."
parameters:
- name: "context"
type: "<xref href=\"com.azure.core.http.HttpPipelineCallContext?alt=com.azure.core.http.HttpPipelineCallContext&text=HttpPipelineCallContext\" data-throw-if-not-resolved=\"False\" />"
- name: "next"
type: "<xref href=\"com.azure.core.http.HttpPipelineNextPolicy?alt=com.azure.core.http.HttpPipelineNextPolicy&text=HttpPipelineNextPolicy\" data-throw-if-not-resolved=\"False\" />"
syntax: "public Mono<HttpResponse> process(HttpPipelineCallContext context, HttpPipelineNextPolicy next)"
desc: "Processes provided request context and invokes the next policy."
returns:
type: "<a href=\"https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html\">Mono</a>&lt;<xref href=\"com.azure.core.http.HttpResponse?alt=com.azure.core.http.HttpResponse&text=HttpResponse\" data-throw-if-not-resolved=\"False\" />&gt;"
- uid: "com.azure.core.http.policy.RetryPolicy.processSync(com.azure.core.http.HttpPipelineCallContext,com.azure.core.http.HttpPipelineNextSyncPolicy)"
fullName: "com.azure.core.http.policy.RetryPolicy.processSync(HttpPipelineCallContext context, HttpPipelineNextSyncPolicy next)"
name: "processSync(HttpPipelineCallContext context, HttpPipelineNextSyncPolicy next)"
nameWithType: "RetryPolicy.processSync(HttpPipelineCallContext context, HttpPipelineNextSyncPolicy next)"
summary: "Processes provided request context and invokes the next policy synchronously."
parameters:
- name: "context"
type: "<xref href=\"com.azure.core.http.HttpPipelineCallContext?alt=com.azure.core.http.HttpPipelineCallContext&text=HttpPipelineCallContext\" data-throw-if-not-resolved=\"False\" />"
- name: "next"
type: "<xref href=\"com.azure.core.http.HttpPipelineNextSyncPolicy?alt=com.azure.core.http.HttpPipelineNextSyncPolicy&text=HttpPipelineNextSyncPolicy\" data-throw-if-not-resolved=\"False\" />"
syntax: "public HttpResponse processSync(HttpPipelineCallContext context, HttpPipelineNextSyncPolicy next)"
desc: "Processes provided request context and invokes the next policy synchronously."
returns:
type: "<xref href=\"com.azure.core.http.HttpResponse?alt=com.azure.core.http.HttpResponse&text=HttpResponse\" data-throw-if-not-resolved=\"False\" />"
type: "class"
desc: "The `RetryPolicy` class is an implementation of the <xref uid=\"com.azure.core.http.policy.HttpPipelinePolicy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"HttpPipelinePolicy\"></xref> interface. This policy handles HTTP retries by determining if an HTTP request should be retried based on the received <xref uid=\"com.azure.core.http.HttpResponse\" data-throw-if-not-resolved=\"false\" data-raw-source=\"HttpResponse\"></xref>.\n\nThis class is useful when you need to handle HTTP retries in a pipeline. It uses a <xref uid=\"com.azure.core.http.policy.RetryStrategy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryStrategy\"></xref> to decide if a request should be retried. By default, it uses the <xref uid=\"com.azure.core.http.policy.ExponentialBackoff\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ExponentialBackoff\"></xref> strategy, which uses a delay duration that exponentially increases with each retry attempt until an upper bound is reached.\n\n**Code sample:**\n\nIn this example, a `RetryPolicy` is created which can then be added to the pipeline. For the request then sent by the pipeline, if the server responds with a status code that indicates a transient error, the request will be retried according to the <xref uid=\"com.azure.core.http.policy.RetryStrategy\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RetryStrategy\"></xref> used by the `RetryPolicy`.\n\n```java\nRetryPolicy retryPolicy = new RetryPolicy();\n```"
implements:
- "<xref href=\"com.azure.core.http.policy.HttpPipelinePolicy?alt=com.azure.core.http.policy.HttpPipelinePolicy&text=HttpPipelinePolicy\" data-throw-if-not-resolved=\"False\" />"
metadata: {}
package: "com.azure.core.http.policy"
artifact: com.azure:azure-core:1.52.0