I 'm using the eureka-client in the spring boot2. However, the eureka server is off and a connection error is output. I want to catch the error and do something else. How do I handle exceptions in case of connection error for the eureka client ?
-------------- exception ------------------
com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:112) ~[eureka-client-1.9.3.jar:1.9.3]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) ~[eureka-client-1.9.3.jar:1.9.3]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$6.execute(EurekaHttpClientDecorator.java:137) ~[eureka-client-1.9.3.jar:1.9.3]
at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77) ~[eureka-client-1.9.3.jar:1.9.3]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) ~[eureka-client-1.9.3.jar:1.9.3]
Comment From: spencergibb
No need to cross post https://github.com/Netflix/eureka/issues/1111
How are you using the eureka client?
Comment From: JangCool
i'm using the openfeign and the eureka-client.
Maybe. I think will work behind at the eureka-client when using the openfeign.
I want to handle exceptions for connection errors.
----application -----
@SpringBootApplication @EnableFeignClients public class Application {
---- openfeign call -------
@FeignClient(name = "gateway") public interface SampleClient {
@RequestMapping(method=RequestMethod.GET, value="/article/sports/{category}")
public String getData(@PathVariable("category") String category);
}
---- pom.xml ----
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>
Comment From: spencergibb
Eureka client works asynchronously. There is no way to handle those errors.
Comment From: linux2014linux
@spencergibb Is there any active way to catch such errors?Do I only wait other server happen error?