1. Zuul gateway configuration retry

As a unified gateway for back-end services, the gateway can add retry in the case of cluster, and can be routed to other instances when one instance is blocked to achieve high availability of services

1. Add dependencies

<dependency>
    <groupId>org.springframework.retry</groupId>
    <artifactId>spring-retry</artifactId>
</dependency>
Copy the code

2. Add the configuration

Zuul: retryable: true ribbon: # per server retries, but are not included in the first call MaxAutoRetries: 0 # again up how many servers MaxAutoRetriesNextServer: 4Copy the code

2. Fegin retry

Fegin is a tool for inter-service invocation, invoking by service name and adding retries if there are multiple instances of the invoked service

Feign: hystrix: enabled: true ribbon: OkToRetryOnAllOperations: true # to retry all operation request, the default false ReadTimeout: ConnectTimeout: 4000 #ribbon Specifies the timeout period for a connection. Default value: 2000 MaxAutoRetries: 0 # retry count for the current instance, the default is 0 MaxAutoRetriesNextServer: 1 # retries to switch case, the default 1 hystrix: command: default: If enabled is set to false, the ribbon controls the execution: timeout request. If enabled is set to true, the ribbon controls the execution: timeout request. True Isolation: Thread: timeoutInMilliseconds: 7000 # Circuit breaker timeout, default 1000msCopy the code