DatTrink
DatTrink

Reputation: 3

Is there any way for API Gateway to find the User service immediately?

I'm having a problem with Eureka. I have 3 components:

@Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
        return builder.routes()
                // User service
                .route(r -> r.path("/user-service/**")
                        .filters(f -> f.rewritePath("/user-service/", "/").dedupeResponseHeader(HttpHeader.ACCESS_CONTROL_ALLOW_ORIGIN, HttpHeader.RETAIN_UNIQUE))
                        .uri("lb://USER-SERVICE"))

                .build();
    }

I start Eureka and API Gateway first, then start User service. I access the user service through API Gateway (http://localhost:2001/user-service) but error "Unable to find instance for USER-SERVICE" is display, and a few seconds later, it works.

error message

Is there any way for API Gateway to find the User service immediately?

Upvotes: 0

Views: 660

Answers (1)

Toni
Toni

Reputation: 5125

You can change the property indicating how often(in seconds) to fetch the registry information from the eureka server. The default value is 30s as can be found on the link.

eureka.client.registry-fetch-interval-seconds=30s

Upvotes: 0

Related Questions