0
votes

I've encountered an issue with @RefreshScope and it's behaviour. Two main queries:

  1. When the refresh endpoint is invoked, the service effectively restarts and unregisters, then re-registers with Eureka. I thought refreshing the scope would in the main be non-service affecting?

  2. My service starts on a random port, i.e. I've set server.port to be 0 in my properties. The restart mentioned above changes initial value assigned to the server port, and changes it to be 0 for the purpose of registering with Eureka. This means the service is effectively uncontactable to any Ribbon/eureka aware load balancer.

See my sample project here:

https://github.com/KramKroc/refreshscope

1
Works for me with Brixton snapshots (the service is not restarting, it's just re-registering). There have been quite a few changes in Eureka lately, so please try that and let us know what happens. The support for server.port=0 was never very good in Angel. - Dave Syer
@DaveSyer thanks for the rapid feedback. Unfortunately the commute and kids meant i only got to look again at this now. I've done a couple of things: 1. Changed gradle to pull in Brixton snapshots as suggested 2. Added a zuul proxy which highlights the ribbon/load balancing issue I mentioned. Issue still happens with SNAPSHOT and the service to my mind restarts (but seems quicker to do so). These changes are pushed to github.com/KramKroc/refreshscope - KramKroc
The clarify the restart, it does a soft restart rather than a hard restart of the application. - KramKroc

1 Answers

0
votes

Thanks to @DaveSyer I was able to get to the bottom of this issue. In my bootstrap.yml in sample-service (see https://github.com/KramKroc/refreshscope) I had the following line:

eureka: instance: nonSecurePort: ${server.port:8082}

This was incorrect as it caused the service to re-register with eureka on the server.port (which was set to zero) or 8082 if not defined. Removing the nonSecurePort entry allowed the service to be refreshed and still be registered with the correct (random) port in Eureka.