0

I'm using ribbon and eureka and I want add the following property:

my-service.ribbon.ServerListRefreshInterval

However, the default context doesn't see this property. I'm using ribbon as a loadBalancer. Currently I fixed it by using:

 ConfigurationManager.loadPropertiesFromResources("my-service.properties");

Is this the only way to fix this?

Example of my code:

@Component
public class ServiceClientFactory 
{
    @Inject
    public ServiceClientFactory(
    private String applicationName="firstApp";

    final SpanAccessor spanAccessor
            final LoadBalancerClient loadBalancer,
            ) throws IOException {

            loadBalancer.choose(applicationName);

    }
}
@SpringBootApplication
@EnableEurekaClient
public class ServiceApplication extends SpringBootServletInitializer {
    public static void main(String[] args) {
        new ServiceApplication()
                .configure(new SpringApplicationBuilder(ServiceApplication.class))
                .run(args);
    }
}
g00glen00b
  • 41,995
  • 13
  • 95
  • 133
  • Is it not working when you are giving this property in application.properties file? if not then could you please share your code? – Vicky Feb 20 '18 at 18:55
  • @Gaurav, yes it's not working when I put this property in application.properties – Иван Гладуш Feb 20 '18 at 19:28
  • Can you share your code? you can create a github repository and place your code there, as if I am trying this, it is working for me. – Vicky Feb 20 '18 at 19:38
  • I have tried this without eureka service discovery and it is working in that case. see https://github.com/vickygupta0017/microservice-ribbon – Vicky Feb 20 '18 at 19:42
  • @Gaurav I can't show code now, only tomorrow. And I don't user ribbon client I just use ribbonLoadBalancer. – Иван Гладуш Feb 20 '18 at 19:51
  • @Gaurav I added the example of code. – Иван Гладуш Feb 21 '18 at 06:58
  • 1
    It is very difficult to give conclusion without seeing the actual code, but I have tried to consume a eureka enable service with the ribbon(load balancing), and it is successfully taking the serverListRefreshInterval from the application.properties file. see code at (https://github.com/vickygupta0017/microservice-ribbon). – Vicky Feb 21 '18 at 09:17

0 Answers0