diff --git a/dropwizard-app/src/main/resources/config.yml b/dropwizard-app/src/main/resources/config.yml index 2c6db9f..73345d0 100644 --- a/dropwizard-app/src/main/resources/config.yml +++ b/dropwizard-app/src/main/resources/config.yml @@ -25,6 +25,7 @@ database: exchangeClientConfig: basePath: 'http://localhost:8888/exchanges?currency=' + timeout: 5s # default=0.5s logging: level: INFO diff --git a/micronaut-app/src/main/resources/application.yml b/micronaut-app/src/main/resources/application.yml index 3604245..add6f5a 100644 --- a/micronaut-app/src/main/resources/application.yml +++ b/micronaut-app/src/main/resources/application.yml @@ -14,7 +14,7 @@ micronaut: services: exchange-client: url: "http://localhost:8888" - read-timeout: 1m + read-timeout: 5s # default=10s endpoints: all: port: 8081 diff --git a/quarkus-app/src/main/resources/application.properties b/quarkus-app/src/main/resources/application.properties index b58785c..f4ff32b 100644 --- a/quarkus-app/src/main/resources/application.properties +++ b/quarkus-app/src/main/resources/application.properties @@ -14,6 +14,8 @@ quarkus.datasource.jdbc.url = jdbc:postgresql://localhost:5432/postgres quarkus.hibernate-orm.database.generation = drop-and-create quarkus.rest-client.exchange-client.url=http://localhost:8888 +# Default '30000' +quarkus.rest-client.exchange-client.read-timeout=5000 quarkus.rest-client.exchange-client.scope=jakarta.inject.Singleton # https://quarkus.io/guides/cdi-reference#bean_discovery diff --git a/spring-app/src/main/java/bitxon/spring/client/ExchangeClientConfig.java b/spring-app/src/main/java/bitxon/spring/client/ExchangeClientConfig.java index a41bb36..699ec6c 100644 --- a/spring-app/src/main/java/bitxon/spring/client/ExchangeClientConfig.java +++ b/spring-app/src/main/java/bitxon/spring/client/ExchangeClientConfig.java @@ -7,14 +7,19 @@ import org.springframework.web.reactive.function.client.support.WebClientAdapter; import org.springframework.web.service.invoker.HttpServiceProxyFactory; +import java.time.Duration; + @Configuration public class ExchangeClientConfig { @Bean - public ExchangeClient exchangeClient(@Value("${http.exchange-client.url}") String url) { - var webClient = WebClient.create(url); - var factory = HttpServiceProxyFactory.builder(WebClientAdapter.forClient(webClient)).build(); - var serviceClient = factory.createClient(ExchangeClient.class); - return serviceClient; + public ExchangeClient exchangeClient(@Value("${http.exchange-client.url}") String url, + @Value("${http.exchange-client.block-timeout}") Duration blockTimeout, + WebClient.Builder webClientBuilder) { + var webClient = webClientBuilder.baseUrl(url).build(); + var factory = HttpServiceProxyFactory.builder(WebClientAdapter.forClient(webClient)) + .blockTimeout(blockTimeout) + .build(); + return factory.createClient(ExchangeClient.class); } } diff --git a/spring-app/src/main/resources/application.yml b/spring-app/src/main/resources/application.yml index 8bb79cc..e3aa9dc 100644 --- a/spring-app/src/main/resources/application.yml +++ b/spring-app/src/main/resources/application.yml @@ -25,6 +25,7 @@ spring: http: exchange-client: url: http://localhost:8888 + block-timeout: 5s # default=5s logging: level: