Skip to content

Commit

Permalink
Merge pull request #349 from navikt/feature/timeout-retry
Browse files Browse the repository at this point in the history
Endret litt på retry- og timeout-konfig
  • Loading branch information
LarsOttoHaugen authored Jun 19, 2024
2 parents b11ceb2 + 5c0146b commit 466ba1f
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class BidragGrunnlagConfig {
fun restTemplate(): HttpHeaderRestTemplate {
val httpHeaderRestTemplate = HttpHeaderRestTemplate()

val sc = SocketConfig.custom().setSoTimeout(Timeout.ofSeconds(3)).build()
val sc = SocketConfig.custom().setSoTimeout(Timeout.ofSeconds(10)).build()
val pb = PoolingHttpClientConnectionManagerBuilder.create().setDefaultSocketConfig(sc).build()
val connectionManager = HttpClientBuilder.create().setConnectionManager(pb).build()
val requestFactory = HttpComponentsClientHttpRequestFactory(connectionManager)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.springframework.core.ParameterizedTypeReference
import org.springframework.http.HttpMethod
import org.springframework.retry.annotation.Backoff
import org.springframework.retry.annotation.Retryable
import java.net.SocketTimeoutException

private const val AAREG_CONTEXT = "/api/v2/arbeidstaker/arbeidsforhold"

Expand All @@ -25,7 +26,7 @@ open class ArbeidsforholdConsumer(private val restTemplate: HttpHeaderRestTempla
val LOGGER: Logger = LoggerFactory.getLogger(ArbeidsforholdConsumer::class.java)
}

@Retryable(value = [Exception::class], backoff = Backoff(delay = 500))
@Retryable(value = [Exception::class], exclude = [SocketTimeoutException::class], backoff = Backoff(delay = 500))
open fun hentArbeidsforhold(request: HentArbeidsforholdRequest): RestResponse<List<Arbeidsforhold>> {
SECURE_LOGGER.info("Henter arbeidsforhold fra Aareg med request: ${tilJson(request)}")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory
import org.springframework.http.HttpMethod
import org.springframework.retry.annotation.Backoff
import org.springframework.retry.annotation.Retryable
import java.net.SocketTimeoutException

open class EnhetsregisterConsumer(private val restTemplate: HttpHeaderRestTemplate) :
GrunnlagsConsumer() {
Expand All @@ -22,7 +23,7 @@ open class EnhetsregisterConsumer(private val restTemplate: HttpHeaderRestTempla
val LOGGER: Logger = LoggerFactory.getLogger(EnhetsregisterConsumer::class.java)
}

@Retryable(value = [Exception::class], backoff = Backoff(delay = 500))
@Retryable(value = [Exception::class], exclude = [SocketTimeoutException::class], backoff = Backoff(delay = 500))
open fun hentEnhetsinfo(request: HentEnhetsregisterRequest): RestResponse<HentEnhetsregisterResponse> {
LOGGER.info("Henter info om en organisasjon fra Ereg")
SECURE_LOGGER.info("Henter info om en organisasjon fra Ereg med request: ${tilJson(request)}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import org.springframework.core.ParameterizedTypeReference
import org.springframework.http.HttpMethod
import org.springframework.retry.annotation.Backoff
import org.springframework.retry.annotation.Retryable
import java.net.SocketTimeoutException

private const val BIDRAGPERSON_CONTEXT_FOEDSEL_DOED = "/bidrag-person/navnfoedseldoed"
private const val BIDRAGPERSON_CONTEXT_FORELDER_BARN_RELASJON = "/bidrag-person/forelderbarnrelasjon"
Expand All @@ -35,7 +36,7 @@ open class BidragPersonConsumer(private val restTemplate: HttpHeaderRestTemplate
val logger: Logger = LoggerFactory.getLogger(BidragPersonConsumer::class.java)
}

@Retryable(value = [Exception::class], backoff = Backoff(delay = 500))
@Retryable(value = [Exception::class], exclude = [SocketTimeoutException::class], backoff = Backoff(delay = 500))
open fun hentNavnFoedselOgDoed(personident: Personident): RestResponse<NavnFødselDødDto> {
logger.debug("Kaller bidrag-person som igjen henter info om fødselsdato og eventuelt død fra PDL")

Expand All @@ -52,7 +53,7 @@ open class BidragPersonConsumer(private val restTemplate: HttpHeaderRestTemplate
return restResponse
}

@Retryable(value = [Exception::class], backoff = Backoff(delay = 500))
@Retryable(value = [Exception::class], exclude = [SocketTimeoutException::class], backoff = Backoff(delay = 500))
open fun hentForelderBarnRelasjon(personident: Personident): RestResponse<ForelderBarnRelasjonDto> {
logger.info("Kaller bidrag-person som igjen henter forelderbarnrelasjoner for angitt person fra PDL")

Expand All @@ -69,7 +70,7 @@ open class BidragPersonConsumer(private val restTemplate: HttpHeaderRestTemplate
return restResponse
}

@Retryable(value = [Exception::class], backoff = Backoff(delay = 500))
@Retryable(value = [Exception::class], exclude = [SocketTimeoutException::class], backoff = Backoff(delay = 500))
open fun hentHusstandsmedlemmer(personident: Personident): RestResponse<HusstandsmedlemmerDto> {
logger.info(
"Kaller bidrag-person som igjen henter info om en persons bostedsadresser " +
Expand All @@ -89,7 +90,7 @@ open class BidragPersonConsumer(private val restTemplate: HttpHeaderRestTemplate
return restResponse
}

@Retryable(value = [Exception::class], backoff = Backoff(delay = 500))
@Retryable(value = [Exception::class], exclude = [SocketTimeoutException::class], backoff = Backoff(delay = 500))
open fun hentSivilstand(personident: Personident): RestResponse<SivilstandPdlHistorikkDto> {
logger.info("Kaller bidrag-person som igjen kaller PDL for å finne en persons sivilstand")

Expand All @@ -106,7 +107,7 @@ open class BidragPersonConsumer(private val restTemplate: HttpHeaderRestTemplate
return restResponse
}

@Retryable(value = [Exception::class], backoff = Backoff(delay = 500))
@Retryable(value = [Exception::class], exclude = [SocketTimeoutException::class], backoff = Backoff(delay = 500))
open fun hentPersonidenter(personident: Personident, inkludereHistoriske: Boolean): RestResponse<List<PersonidentDto>> {
logger.debug("Kaller bidrag-person som igjen kaller PDL for å finne en persons historiske identer")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory
import org.springframework.http.HttpMethod
import org.springframework.retry.annotation.Backoff
import org.springframework.retry.annotation.Retryable
import java.net.SocketTimeoutException

private const val FAMILIEBASAK_CONTEXT = "/api/bisys/hent-utvidet-barnetrygd"

Expand All @@ -23,7 +24,7 @@ open class FamilieBaSakConsumer(private val restTemplate: HttpHeaderRestTemplate
val logger: Logger = LoggerFactory.getLogger(FamilieBaSakConsumer::class.java)
}

@Retryable(value = [Exception::class], backoff = Backoff(delay = 500))
@Retryable(value = [Exception::class], exclude = [SocketTimeoutException::class], backoff = Backoff(delay = 500))
open fun hentFamilieBaSak(request: FamilieBaSakRequest): RestResponse<FamilieBaSakResponse> {
logger.debug("Henter utvidet barnetrygd og småbarnstillegg fra familie-ba-sak")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory
import org.springframework.http.HttpMethod
import org.springframework.retry.annotation.Backoff
import org.springframework.retry.annotation.Retryable
import java.net.SocketTimeoutException

private const val BARNETILSYN_CONTEXT = "/api/ekstern/bisys/perioder-barnetilsyn"

Expand All @@ -24,7 +25,7 @@ open class FamilieEfSakConsumer(
private val logger: Logger = LoggerFactory.getLogger(FamilieEfSakConsumer::class.java)
}

@Retryable(value = [Exception::class], backoff = Backoff(delay = 500))
@Retryable(value = [Exception::class], exclude = [SocketTimeoutException::class], backoff = Backoff(delay = 500))
open fun hentBarnetilsyn(request: BarnetilsynRequest): RestResponse<BarnetilsynResponse> {
logger.debug("Henter barnetilsyn")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory
import org.springframework.http.HttpMethod
import org.springframework.retry.annotation.Backoff
import org.springframework.retry.annotation.Retryable
import java.net.SocketTimeoutException

private const val FAMILIEKSSAK_CONTEXT = "/api/bisys/hent-utbetalingsinfo"

Expand All @@ -23,7 +24,7 @@ open class FamilieKsSakConsumer(private val restTemplate: HttpHeaderRestTemplate
val logger: Logger = LoggerFactory.getLogger(FamilieKsSakConsumer::class.java)
}

@Retryable(value = [Exception::class], backoff = Backoff(delay = 500))
@Retryable(value = [Exception::class], exclude = [SocketTimeoutException::class], backoff = Backoff(delay = 500))
open fun hentKontantstotte(request: BisysDto): RestResponse<BisysResponsDto> {
val restResponse = restTemplate.tryExchange(
FAMILIEKSSAK_CONTEXT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.slf4j.LoggerFactory
import org.springframework.http.HttpMethod
import org.springframework.retry.annotation.Backoff
import org.springframework.retry.annotation.Retryable
import java.net.SocketTimeoutException

private const val INNTEKT_LISTE_CONTEXT = "/rs/api/v1/hentinntektliste"
private const val DETALJERTE_ABONNERTE_INNTEKTER_CONTEXT = "/rs/api/v1/hentdetaljerteabonnerteinntekter"
Expand All @@ -25,7 +26,7 @@ open class InntektskomponentenConsumer(private val restTemplate: HttpHeaderRestT
val LOGGER: Logger = LoggerFactory.getLogger(InntektskomponentenConsumer::class.java)
}

@Retryable(value = [Exception::class], backoff = Backoff(delay = 500))
@Retryable(value = [Exception::class], exclude = [SocketTimeoutException::class], backoff = Backoff(delay = 500))
open fun hentInntekter(request: HentInntektListeRequest, abonnerteInntekterRequest: Boolean): RestResponse<HentInntektListeResponse> {
if (abonnerteInntekterRequest) {
LOGGER.debug("Henter abonnerte inntekter fra Inntektskomponenten.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.springframework.http.HttpMethod
import org.springframework.retry.annotation.Backoff
import org.springframework.retry.annotation.Retryable
import org.springframework.web.util.UriComponentsBuilder
import java.net.SocketTimeoutException

private const val BARNETILLEGG_URL = "/pen/api/barnetillegg/search"

Expand All @@ -24,7 +25,7 @@ open class PensjonConsumer(private val restTemplate: HttpHeaderRestTemplate) : G
val LOGGER: Logger = LoggerFactory.getLogger(PensjonConsumer::class.java)
}

@Retryable(value = [Exception::class], backoff = Backoff(delay = 500))
@Retryable(value = [Exception::class], exclude = [SocketTimeoutException::class], backoff = Backoff(delay = 500))
open fun hentBarnetilleggPensjon(request: HentBarnetilleggPensjonRequest): RestResponse<List<BarnetilleggPensjon>> {
val uri = UriComponentsBuilder.fromPath(BARNETILLEGG_URL)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.springframework.http.HttpMethod
import org.springframework.retry.annotation.Backoff
import org.springframework.retry.annotation.Retryable
import org.springframework.web.util.UriComponentsBuilder
import java.net.SocketTimeoutException

private const val SUMMERT_SKATTEGRUNNLAG_URL = "/api/v1/summertskattegrunnlag"
private const val INNTEKTSAAR = "inntektsaar"
Expand All @@ -25,7 +26,7 @@ open class SigrunConsumer(private val restTemplate: HttpHeaderRestTemplate) : Gr
val LOGGER: Logger = LoggerFactory.getLogger(SigrunConsumer::class.java)
}

@Retryable(value = [Exception::class], backoff = Backoff(delay = 500))
@Retryable(value = [Exception::class], exclude = [SocketTimeoutException::class], backoff = Backoff(delay = 500))
open fun hentSummertSkattegrunnlag(request: HentSummertSkattegrunnlagRequest): RestResponse<HentSummertSkattegrunnlagResponse> {
val uri = UriComponentsBuilder.fromPath(SUMMERT_SKATTEGRUNNLAG_URL)
.queryParam(INNTEKTSAAR, request.inntektsAar)
Expand Down

0 comments on commit 466ba1f

Please sign in to comment.