Skip to content

Commit

Permalink
pågående jobb barnetrygdinformasjon (lagring i db)
Browse files Browse the repository at this point in the history
  • Loading branch information
jankroken-nav committed Oct 24, 2024
1 parent f3cde4c commit 22a0cb5
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.config

import io.getunleash.Unleash
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.domain.BarnetrygdmottakerService
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.domain.SendTilBestemService
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.monitorering.StatusCheckTask
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.monitorering.StatusRapporteringCachingAdapter
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.repository.BarnetrygdmottakerRepository
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.metrics.Metrikker
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.tasks.BarnetrygdmottakerProcessingTask
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.tasks.FrigiLaserTask
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.tasks.SendTilBestemTask
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Profile
Expand Down Expand Up @@ -41,4 +43,13 @@ class ScheduledTasksConfig(
unleash = unleash,
)
}

@Bean
fun sendToBestemTask(sendTilBestemService: SendTilBestemService): SendTilBestemTask {
return SendTilBestemTask(
service = sendTilBestemService,
metrikker = metrikker,
unleash = unleash,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class UnleashConfig(

enum class Feature(val toggleName: String) {
PROSESSER_BARNETRYGDMOTTAKER("omsorgsopptjening-start-innlesning-prosesser-barnetrygdmottaker"),
SEND_TIL_BESTEM("omsorgsopptjening-start-innlesning-send-til-bestem"),
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Metrikker(private val registry: MeterRegistry) {
private val hentPdlTimer = registry.timer("hentpdl", "tidsbruk", "hentet")

private val antallFeiledeMeldinger = registry.counter("meldinger", "antall", "feilet")
private val antallSendtTilBestem = registry.counter("barnetrygdinformasjon", "antall", "sendt")

private val antallKlar = registry.counter("barnetrygdmottaker", "status", "klar")
private val antallFerdig = registry.counter("barnetrygdmottaker", "status", "ferdig")
Expand Down Expand Up @@ -73,4 +74,8 @@ class Metrikker(private val registry: MeterRegistry) {
fun målFeiletMelding(lambda: () -> Unit) {
antallFeiledeMeldinger.increment()
}

fun tellSendtTilBestem(antall: Int) {
antallSendtTilBestem.increment(antall.toDouble())
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
package no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.tasks

import io.getunleash.Unleash
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.domain.BarnetrygdmottakerService
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.domain.Barnetrygdinformasjon
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.domain.SendTilBestemService
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.config.UnleashConfig
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.metrics.Metrikker
import org.slf4j.LoggerFactory
import org.springframework.scheduling.annotation.Scheduled

class SendToBestemTask(
private val service: BarnetrygdmottakerService,
class SendTilBestemTask(
private val service: SendTilBestemService,
private val metrikker: Metrikker,
private val unleash: Unleash,
) : Runnable {

companion object {
val log = LoggerFactory.getLogger(SendToBestemTask::class.java)!!
val log = LoggerFactory.getLogger(SendTilBestemTask::class.java)!!
}

@Scheduled(fixedDelay = 1000)
@Scheduled(fixedDelay = 5000)
override fun run() {
try {
if (isEnabled()) {
Expand All @@ -34,17 +35,18 @@ class SendToBestemTask(
log.info("Sender all tilgjengelig barnetrygdinformasjon til bestem (via kafka)")
var harGjortNoe = true
while (harGjortNoe) {
val barnetrygdmottakere = metrikker.tellBarnetrygdmottakerStatus {
service.process()
val prosessert: List<Barnetrygdinformasjon>? = service.process()
if (prosessert?.isNotEmpty() == true) {
metrikker.tellSendtTilBestem(prosessert.size)
}
harGjortNoe = !barnetrygdmottakere.isNullOrEmpty()
val harGjortNoe = prosessert.isNullOrEmpty()
if (harGjortNoe) {
log.info("Prosessert ${barnetrygdmottakere?.size} barnetrygdmottakere")
log.info("Prosessert ${prosessert?.size} barnetrygdmottakere")
}
}
}

private fun isEnabled(): Boolean {
return unleash.isEnabled(UnleashConfig.Feature.PROSESSER_BARNETRYGDMOTTAKER.toggleName)
return unleash.isEnabled(UnleashConfig.Feature.SEND_TIL_BESTEM.toggleName)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.d
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.domain.Barnetrygdinformasjon
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.domain.Barnetrygdmottaker
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import java.time.Instant
Expand Down

0 comments on commit 22a0cb5

Please sign in to comment.