I have a Spring Application with multiple services, eureka client and Spring cloud gateway to interact with services, the problem is from gateway client I am able to send request to the service in my service application's log I can see its arriving there but I am not able to get the response in my gateway application, my service is taking aroung 2-2.5 seconds to complete the request.
My Gateway Server Config:-
return route -> route.path("/" + serviceName + "/**")
.filters(
filter -> filter.rewritePath("/" + serviceName + "", "/")
.circuitBreaker(circuit -> circuit.setName(DEFAULT_CIRCUIT_BREAKER)
.setFallbackUri("forward:/service/" + fallbackUrl)))
.uri("lb://" + serviceName + "");
here is my circuit breaker config:-
@Bean
public Customizer<Resilience4JCircuitBreakerFactory> circuitBreaker() {
return factory -> factory.configureDefault(id -> new Resilience4JConfigBuilder(id)
.timeLimiterConfig(TimeLimiterConfig.custom().timeoutDuration(Duration.ofSeconds(10)).build())
.circuitBreakerConfig(io.github.resilience4j.circuitbreaker.CircuitBreakerConfig.ofDefaults()).build());
}
I also tried configuring per route response and timeout like below:-
return route -> route.path("/" + serviceName + "/**")
.filters(
filter -> filter.rewritePath("/" + serviceName + "", "/")
.circuitBreaker(circuit -> circuit.setName(DEFAULT_CIRCUIT_BREAKER)
.setFallbackUri("forward:/service/" + fallbackUrl)))
.metadata(RouteMetadataUtils.RESPONSE_TIMEOUT_ATTR, 5000)
.uri("lb://" + serviceName + "");
here is my application.yml file:-
cloud:
gateway:
httpclient:
connect-timeout: 10000
response-timeout: 10s
what I am doing wrong