Skip to content

Commit

Permalink
Remove JacksonExchangeStrategyUtil and update WebClient configs
Browse files Browse the repository at this point in the history
Deleted the unused JacksonExchangeStrategyUtil class and introduced new WebClient configurations in AaregConsumer and PdlConsumer for better connection handling and performance efficiency. This change aims to improve connection stability and responsiveness in reactive web client interactions.
  • Loading branch information
krharum committed Oct 14, 2024
1 parent bae72b1 commit 12d39e6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package no.nav.testnav.levendearbeidsforholdansettelse.consumers;

import io.netty.channel.ChannelOption;
import io.netty.channel.epoll.EpollChannelOption;
import lombok.extern.slf4j.Slf4j;
import no.nav.testnav.levendearbeidsforholdansettelse.config.Consumers;
import no.nav.testnav.levendearbeidsforholdansettelse.consumers.command.aareg.HentArbeidsforholdCommand;
Expand All @@ -9,9 +11,14 @@
import no.nav.testnav.libs.standalone.servletsecurity.exchange.TokenExchange;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Flux;
import reactor.netty.http.client.HttpClient;
import reactor.netty.resources.ConnectionProvider;

import java.time.Duration;

@Slf4j
@Component
Expand All @@ -31,6 +38,21 @@ public AaregConsumer(

this.webClient = webClientBuilder
.baseUrl(serverProperties.getUrl())
.clientConnector(
new ReactorClientHttpConnector(
HttpClient
.create(ConnectionProvider.builder("AaregConsumer")
.maxConnections(1)
.pendingAcquireMaxCount(10000)
.pendingAcquireTimeout(Duration.ofSeconds(300))
.build())
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000)
.option(ChannelOption.SO_KEEPALIVE, true)
.option(EpollChannelOption.TCP_KEEPIDLE, 300)
.option(EpollChannelOption.TCP_KEEPINTVL, 60)
.option(EpollChannelOption.TCP_KEEPCNT, 8)
.responseTimeout(Duration.ofSeconds(10))
))
.build();
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package no.nav.testnav.levendearbeidsforholdansettelse.consumers;

import io.netty.channel.ChannelOption;
import io.netty.channel.epoll.EpollChannelOption;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import no.nav.testnav.levendearbeidsforholdansettelse.config.Consumers;
Expand Down Expand Up @@ -49,7 +47,7 @@ public PdlConsumer(
new ReactorClientHttpConnector(
HttpClient
.create(ConnectionProvider.builder("PDL connections")
.maxConnections(10)
.maxConnections(1)
.pendingAcquireMaxCount(10000)
.pendingAcquireTimeout(Duration.ofSeconds(30))
.build())))
Expand Down

0 comments on commit 12d39e6

Please sign in to comment.