Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: timeout webclient (occured when eno generation is too long) #304

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.0</version>
<version>3.3.1</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>

<groupId>fr.insee</groupId>
<artifactId>Pogues-BO</artifactId>
<packaging>jar</packaging>
<version>4.7.4</version>
<version>4.7.5-SNAPSHOT</version>
<name>Pogues-Back-Office</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>21</java.version>
<final.asset.name>pogues-bo</final.asset.name>
<pogues-model.version>1.3.7</pogues-model.version>
<pogues-model.version>1.3.12</pogues-model.version>
<fop.version>2.9</fop.version>
<springdoc-openapi-ui.version>2.5.0</springdoc-openapi-ui.version>
<springdoc-openapi-ui.version>2.6.0</springdoc-openapi-ui.version>
<jacoco.version>0.8.12</jacoco.version>
<saxon.version>12.4</saxon.version>
<liquibase.version>4.28.0</liquibase.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.netty.http.client.HttpClient;

import java.time.Duration;

@Configuration
@EnableConfigurationProperties
Expand All @@ -23,13 +27,22 @@ public class AppConfiguration {
@Autowired
private ExchangeFilterFunction webClientTokenInterceptor;

/* Timeout value in seconds */
@Value("${feature.webclient.timeout}")
long webClientTimeout;

@Bean
public WebClient webClient(
@Value("${feature.oidc.enabled}") boolean oidcEnabled,
WebClient.Builder builder) {

HttpClient httpClient = HttpClient.create()
.responseTimeout(Duration.ofSeconds(webClientTimeout));

builder
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.defaultHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE);
.defaultHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
.clientConnector(new ReactorClientHttpConnector(httpClient));
if(oidcEnabled) builder.filter(webClientTokenInterceptor);
return builder.build();
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,7 @@ feature:
magma: 7 # in days
pogues:
stamps: 1 # in days
webclient:
timeout: 120 # in seconds

################################