Closed proragab closed 7 years ago
I think this belongs in Spring Cloud consul.
I posted it there , Thanks
@spencergibb I think this needs to be fixed in spring cloud netflix. DiscoveryClientRouteLocator constructor assumes that "getLocalServiceInstance" will return something or null. Instead it should see if discovery client provider is throwing any exception and if there is any exception then inject noop implementation. I would personally like to see fail-fast flag for discovery client.
public DiscoveryClientRouteLocator(String servletPath, DiscoveryClient discovery,
ZuulProperties properties) {
super(servletPath, properties);
if (properties.isIgnoreLocalService()) {
ServiceInstance instance = discovery.getLocalServiceInstance();
if (instance != null) {
String localServiceId = instance.getServiceId();
if (!properties.getIgnoredServices().contains(localServiceId)) {
properties.getIgnoredServices().add(localServiceId);
}
}
}
this.serviceRouteMapper = new SimpleServiceRouteMapper();
this.discovery = discovery;
this.properties = properties;
}
I tried to register spring micro service on consul with spring retry option , in usual case the spring boot app retry to connect to consul by default 6 times , when i add @EnableZuulProxy the boot couldn't start and throws
==>org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat .. .. .. Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cloud.netflix.zuul.ZuulConfiguration$ZuulFilterConfiguration': Unsatisfied dependency expressed through field 'filters'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'preDecorationFilter' defined in class path resource [org/springframework/cloud/netflix/zuul/ZuulProxyConfiguration.class]: Unsatisfied dependency expressed through method 'preDecorationFilter' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'routeLocator' defined in class path resource [org/springframework/cloud/netflix/zuul/ZuulProxyConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.netflix.zuul.filters.discovery.DiscoveryClientRouteLocator]: Factory method 'routeLocator' threw exception; nested exception is com.ecwid.consul.transport.TransportException: java.net.ConnectException: Connection refused: connect