Hello,
Version: Hoxton.RELEASE
Problem Statement:
Looking at the code CloudEurekaClient's getInstanceInfo(String, String) would be a good candidate. However some of these methods are not provided by [EurekaClient].(https://github.com/Netflix/eureka/blob/6438fba6a42a6d2a1dd2e4cb48eab66c34bd0a21/eureka-client/src/main/java/com/netflix/discovery/EurekaClient.java#L29) interface.
I have a special service that invokes other services on cloud foundry. However, I noticed that there were some edge cases of where eureka client and server were out of sync due to rolling deployment. So in my special service, I would like to check with eureka server if it has the status of a specific service and instance id for safety.
My goal is to: In between the periodic 30s sync between eureka server and client, if my client cache seems to be outdated, I want to ask the eureka server directly or force synchronization manually because I have to use a sticky call to that very specific service instance.
Questions / Requests:
I am aware that EurekaClient is maintained by netflix eureka but I would like to ask for a feature/way to do the followings:
1. How can I make use of CloudEurekaClient by injecting EurekaClient? Would I have to override it using javaconfig?
It seems that if I inject EurekaClient, it is an instance of CloudEurekaClient but I cannot seem to cast it because it is a jdk proxy instance. Ideal code for me would be
@Autowired
EurekaClient eurekaClient;
((CloudEurekaClient) eurekaClient).getInstanceInfo(serviceName, instanceId); // this won't work
- Another good way would be to manually trigger fetching a full list from the server and update local cache. I saw that this is provided somewhere but it was limited with private access. I think it was used during the registration upon startup. Sample would look as like
@Autowired
EurekaClient eurekaClient;
eurakeClient.forceFetchAndUpdateLocalStore(); // let this update local cache manually
Please let me know.
Thanks.
Comment From: holy12345
@jskim1991 Hi man
FIRST
if my client cache seems to be outdated, I want to ask the eureka server directly or force synchronization manually
According to my understanding, Eureka server provides APIs, which allow you to tell Eureka server to let a specific client go offline or go online again later (registration, cancellation events). When these events arrive, the internal cache of Eureka server is updated immediately. The only thing you need to do is you may need to wait for 30s (maybe the longest time) (when the client gets the cache again)
SECOND As far as I know, the principle of Eureka design is AP, that is, it does not have the function of real-time notification to the client. At present, it is only the client who actively asks Eureka serve
For this problem, I think we can solve it through some other ways. The solutions I come up with are as follows:
Opt 1: You can adopt a specific deployment strategy for this special client, and ensure that there is a server that can provide services at any time
Opt2: If you want to adopt the active notification function of the registry, you can use other components as the new registry.
Others:
For your point of view eurakeClient.forceFetchAndUpdateLocalStore (), I think we need to add one more item, that is, in addition to triggering the update mechanism, we need to ensure that the client in the local cache is up-to-date at this time.
thanks
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.