0

I have a Spring Boot app trying to fetch an instance of a service through Eureka/Ribbon:

@LoadBalanced
@Autowired
RestTemplate restTemplate;

@RequestMapping("/hi")
public String hi(@RequestParam(value="name", defaultValue="superuser") String name) {
    AccountRest account = this.restTemplate.getForObject("http://AUTHENTICATION-SERVICE/authservice/v1/accounts/userId/"+name,
        AccountRest.class);
return "hi, " + account.getId(); 
}

I am manually registering the "AUTHENTICATION-SERVICE", note that this service only needs to register itself, it does not need to query eureka:

public class ServiceDiscoveryManager {

    private ApplicationInfoManager applicationInfoManager;
    private EurekaClient eurekaClient;

    public void start() {
        MyDataCenterInstanceConfig instanceConfig = new MyDataCenterInstanceConfig();
        DefaultEurekaClientConfig clientConfig = new DefaultEurekaClientConfig();

        InstanceInfo instanceInfo = new EurekaConfigBasedInstanceInfoProvider(instanceConfig).get();
        applicationInfoManager = new ApplicationInfoManager(instanceConfig, instanceInfo);
        eurekaClient = new DiscoveryClient(applicationInfoManager, clientConfig);

        applicationInfoManager.getInfo();
        eurekaClient.getApplications();

        instanceInfo.setStatus(InstanceStatus.UP);
    }

    public void stop() {
        eurekaClient.shutdown();
    }

}

Spring wiring for the ServiceDiscoveryManager:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

    <bean id="serviceDiscoveryManager" class="com.embotics.authervice.serviceDiscovery.ServiceDiscoveryManager" init-method="start"/>

</beans>

the authentication-service eureka-client.properties file:

eureka.name=AUTHENTICATION-SERVICE
eureka.appGroup=AUTHENTICATION-SERVICE
eureka.vipAddress=http://localhost:9080
eureka.port.enabled=true
eureka.port=9080
eureka.traffic.enabled=true
eureka.preferSameZone=true
eureka.serviceUrl.default=http://localhost:8000/eureka/
eureka.decoderName=JacksonJson
eureka.healthCheckUrl=http://localhost:9080/authservice/health
eureka.healthCheckPath=/authservice/health

The Eureka Dashboard shows my authentication service as registered:

capture

When I try to get an instance of the authentication-service with the load balancer I receive the following exception:

java.lang.IllegalStateException: No instances available for AUTHENTICATION-SERVICE
    at org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.execute(RibbonLoadBalancerClient.java:90) ~[spring-cloud-netflix-core-1.2.5.RELEASE.jar:1.2.5.RELEASE]

I've confirmed that the load balancer is aware of the authentication-service, but the DynamicServerListLoadBalancer has the allServerList property as empty.

I've been playing with this for a few hours, wondering if some configuration is invalid. Thanks for any help.

g00glen00b
  • 41,995
  • 13
  • 95
  • 133
levacjeep
  • 673
  • 3
  • 6
  • 23

0 Answers0