Skip to content

Commit

Permalink
chore: remove try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
MikAoJk committed Sep 2, 2024
1 parent 48fa25a commit 27bd476
Showing 1 changed file with 25 additions and 31 deletions.
56 changes: 25 additions & 31 deletions src/main/kotlin/no/nav/syfo/Bootstrap.kt
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ fun main() {
val sykmeldingService =
SykmeldingService(
smregisterClient =
SmregisterClient(
smregisterEndpointURL = env.smregisterEndpointURL,
accessTokenClientV2 = accessTokenClientV2,
scope = env.smregisterAudience,
httpClient = httpClient,
),
SmregisterClient(
smregisterEndpointURL = env.smregisterEndpointURL,
accessTokenClientV2 = accessTokenClientV2,
scope = env.smregisterAudience,
httpClient = httpClient,
),
)
val behandlingsutfallService =
BehandlingsutfallService(
Expand Down Expand Up @@ -363,8 +363,10 @@ suspend fun blockingApplicationLogic(
applicationState,
kafkaAivenConsumerReceivedSykmelding,
mottattSykmeldingService,
0
0,
)
kafkaAivenConsumerReceivedSykmelding.unsubscribe()
log.info("Stopper kafkaAivenConsumerReceivedSykmelding")

runKafkaConsumer(
infotrygdOppdateringProducer,
Expand All @@ -373,8 +375,10 @@ suspend fun blockingApplicationLogic(
applicationState,
kafkaAivenConsumerReceivedSykmeldingRetry,
mottattSykmeldingService,
10000
10000,
)
kafkaAivenConsumerReceivedSykmeldingRetry.unsubscribe()
log.info("Stopper kafkaAivenConsumerReceivedSykmeldingRetry")
}
delay(100)
}
Expand All @@ -390,30 +394,20 @@ private suspend fun runKafkaConsumer(
pollTimeMs: Long,
) {
while (applicationState.ready && shouldRun(getCurrentTime())) {
try {
kafkaAivenConsumerReceivedSykmelding
.poll(Duration.ofMillis(pollTimeMs))
.mapNotNull { it.value() }
.forEach { receivedSykmeldingString ->
handleRecords(
session,
infotrygdOppdateringProducer,
infotrygdSporringProducer,
mottattSykmeldingService,
receivedSykmeldingString,
)
}
delay(100)
} catch (ex: Exception) {
log.error("error running sykmelding-consumer", ex)
} finally {
kafkaAivenConsumerReceivedSykmelding.unsubscribe()
log.info(
"Unsubscribed from topic and waiting for 10 seconds before trying again",
)
delay(10_000)
}
kafkaAivenConsumerReceivedSykmelding
.poll(Duration.ofMillis(pollTimeMs))
.mapNotNull { it.value() }
.forEach { receivedSykmeldingString ->
handleRecords(
session,
infotrygdOppdateringProducer,
infotrygdSporringProducer,
mottattSykmeldingService,
receivedSykmeldingString,
)
}
}
delay(100)
}

@WithSpan
Expand Down

0 comments on commit 27bd476

Please sign in to comment.