-
Notifications
You must be signed in to change notification settings - Fork 0
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
Innfør støtte for ny feilhåndtering uten behov #471
base: main
Are you sure you want to change the base?
Changes from all commits
03504bd
94fa22f
4cb1270
e2296ae
1fd1a62
fa13764
a9fb448
5a79c6d
a753569
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package no.nav.helsearbeidsgiver.inntektsmelding.feilbehandler.river | ||
|
||
import kotlinx.serialization.builtins.serializer | ||
import no.nav.hag.utils.bakgrunnsjobb.Bakgrunnsjobb | ||
import no.nav.hag.utils.bakgrunnsjobb.BakgrunnsjobbRepository | ||
import no.nav.hag.utils.bakgrunnsjobb.BakgrunnsjobbStatus | ||
|
@@ -30,7 +31,6 @@ class FeilLytter(rapidsConnection: RapidsConnection, private val repository: Bak | |
BehovType.OPPRETT_SAK, | ||
BehovType.PERSISTER_OPPGAVE_ID, | ||
BehovType.PERSISTER_SAK_ID, | ||
BehovType.JOURNALFOER, | ||
BehovType.LAGRE_JOURNALPOST_ID, | ||
BehovType.NOTIFIKASJON_HENT_ID | ||
) | ||
|
@@ -108,8 +108,9 @@ class FeilLytter(rapidsConnection: RapidsConnection, private val repository: Bak | |
return false | ||
} | ||
val behovFraMelding = fail.utloesendeMelding.toMap()[Key.BEHOV]?.fromJson(BehovType.serializer()) | ||
val skalHaandteres = behovSomHaandteres.contains(behovFraMelding) | ||
sikkerLogger.info("Behov: $behovFraMelding skal håndteres: $skalHaandteres") | ||
val harRetry = fail.utloesendeMelding.toMap()[Key.RETRY]?.fromJson(String.serializer()) | ||
val skalHaandteres = harRetry != null || behovSomHaandteres.contains(behovFraMelding) | ||
Comment on lines
+111
to
+112
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hvis du stoler på at |
||
sikkerLogger.info("Feil skal håndteres: $skalHaandteres") | ||
return skalHaandteres | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package no.nav.helsearbeidsgiver.felles.utils | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
interface Retriable { | ||
|
||
/* | ||
Kunne kanskje bare vært en statisk metode, heller enn interface. | ||
Dersom retryId er null, er det en vanlig pakke og skal behandles | ||
Dersom retryId er satt, må man sjekke om den matcher ens egen listenerId, | ||
bare da skal pakken behandles. | ||
*/ | ||
fun erRetryOgMatcherLytteren(myListenerID: RetryID, retryId: RetryID?): Boolean { | ||
return retryId == null || myListenerID == retryId | ||
} | ||
} | ||
|
||
@Serializable | ||
enum class RetryID { | ||
JOURNALFOER | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package no.nav.helsearbeidsgiver.inntektsmelding.joark | ||
|
||
import kotlinx.serialization.builtins.serializer | ||
import kotlinx.serialization.json.JsonElement | ||
import no.nav.helsearbeidsgiver.dokarkiv.DokArkivClient | ||
import no.nav.helsearbeidsgiver.dokarkiv.domene.Avsender | ||
|
@@ -18,6 +19,8 @@ import no.nav.helsearbeidsgiver.felles.metrics.Metrics | |
import no.nav.helsearbeidsgiver.felles.metrics.recordTime | ||
import no.nav.helsearbeidsgiver.felles.rapidsrivers.model.Fail | ||
import no.nav.helsearbeidsgiver.felles.utils.Log | ||
import no.nav.helsearbeidsgiver.felles.utils.Retriable | ||
import no.nav.helsearbeidsgiver.felles.utils.RetryID | ||
import no.nav.helsearbeidsgiver.utils.collection.mapValuesNotNull | ||
import no.nav.helsearbeidsgiver.utils.json.fromJson | ||
import no.nav.helsearbeidsgiver.utils.json.serializer.UuidSerializer | ||
|
@@ -38,16 +41,19 @@ data class JournalfoerImMelding( | |
|
||
class JournalfoerImRiver( | ||
private val dokArkivClient: DokArkivClient | ||
) : ObjectRiver<JournalfoerImMelding>() { | ||
) : ObjectRiver<JournalfoerImMelding>(), Retriable { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Jeg ville foretrukket å ikke ha dette interfacet, ettersom man helt fint kan være |
||
|
||
private val logger = logger() | ||
private val sikkerLogger = sikkerLogger() | ||
private val LISTENER_ID = RetryID.JOURNALFOER | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LISTENER_ID -> riverId? |
||
|
||
override fun les(json: Map<Key, JsonElement>): JournalfoerImMelding? { | ||
val behovType = Key.BEHOV.lesOrNull(BehovType.serializer(), json) | ||
val retry = Key.RETRY.lesOrNull(RetryID.serializer(), json) | ||
return if ( | ||
setOf(Key.DATA, Key.FAIL).any(json::containsKey) || | ||
(behovType != null && behovType != BehovType.JOURNALFOER) | ||
(behovType != null && behovType != BehovType.JOURNALFOER) || // TODO: kan fjernes | ||
(!erRetryOgMatcherLytteren(LISTENER_ID, retry)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Foreslår å bytte ut |
||
) { | ||
null | ||
} else { | ||
|
@@ -120,7 +126,7 @@ class JournalfoerImRiver( | |
transaksjonId = transaksjonId, | ||
forespoerselId = json[Key.FORESPOERSEL_ID]?.fromJson(UuidSerializer), | ||
utloesendeMelding = json.plus( | ||
Key.BEHOV to BehovType.JOURNALFOER.toJson() | ||
Key.RETRY to LISTENER_ID.toJson(RetryID.serializer()) | ||
) | ||
.toJson() | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fint med error her så lenge vi har klassen. Det er strengt tatt en feil vi burde være klar over, selv om vi ikke gjør stort for å rette den opp om dagen.