Closed mikemikezhu closed 11 months ago
We rely on information from a service registry (i.e., Eureka). Until it provides us with instances for the serviceId
in question, we will not be able to pick an instance while load-balancing. One thing that could help you is to reduce the caching time (https://docs.spring.io/spring-cloud-commons/docs/current/reference/html/#loadbalancer-cache-configuration) so that the map of the available instance will be recreated more often based on new calls to ServiceRegistry.
@OlgaMaciaszek
Thank you so much for your useful suggestions!
Since in our application, we registered the service into the service registry (e.g. Eureka) immediately after Spring application is ready (e.g. @EventListener(ApplicationReadyEvent.class)
), I discovered if slowly starting each service one by one, then the issue is gone. Therefore, it might be caused by the serviceId
is not ready in the service registry, which makes it unable to pick the instance while load-balancing. However, I would like to ask whether Spring Cloud has any callback or notification which could notifies other services that load-balancing is ready and it is safe to pick an instance with serviceId
from the service registry? If not, is it beneficial to have such feature in the later versions?
Thank you so much again and look forward to your reply!
The problem here seems to be with the services not being ready in the ServiceRegistry, which is a whole different architecture component and often comes from an entirely different project/ library that we do not maintain (such as Eureka). The best idea might be to check if your services are ready in the service registry of choice (in this case, Eureka). If the healthy instances are available there, you can run your requests. From the solutions that we provide, you might also try using LoadBalancer Retries that will allow you to retry the call several times if there are any 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.
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.
check service linked
@Girish8262 which link? Please repost.
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.
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.
Project Requirement:
I want to send an HTTP request using Feign Client from
ack-service
tonotification-service
whenack-service
get initialized (e.g. Application is ready) in the Spring Cloud application so thatnotification-service
has the configuration information aboutack-service
Description:
GIVEN we have Eureka server: "discovery-service" and Feign Clients: "ack-service", "notification-service" GIVEN "ack-service" and "notification-service" have registered into "discovery-service" GIVEN "ack-service" listens to
ApplicationReadyEvent
WHEN "ack-service" sends data to "notification-service" using Feign Clients when application is ready THEN we haveLoad balancer does not contain an instance for the service
error messageDetails:
NotificationClient
in ack-service, where we defined the Feign ClientIntraNotificationController
in notification-service, where we implemented the Feign ClientCoreAckHandler
in ack-service, which listens toApplicationReadyEvent
and invoke the Feign ClientThen we have the following error:
Note:
@PostConstruct
, and invoked after dependency injection is done, we have the errorLoad balancer does not contain an instance for the service
(I think it is because the Eureka client is not registered yet at this time)@EventListener(ApplicationReadyEvent.class)
, sometimes we have the errorLoad balancer does not contain an instance for the service
, while sometimes there is working fine@RestController
to handle HTTP requests sent from clients, then this is working fineMy questions are:
Thank you so much for your help!
P.s. Full Log: