Skip to content

Commit

Permalink
IS-2643: Turn off JP-retry in dev (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
geir-waagboe authored Dec 17, 2024
1 parent a847553 commit 570a4b6
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .nais/naiserator-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ spec:
kafka:
pool: nav-dev
env:
- name: JP_RETRY_ENABLED
value: "false"
- name: MQ_HOST_NAME
value: "b27apvl222.preprod.local"
- name: MQ_PORT
Expand Down
2 changes: 2 additions & 0 deletions .nais/naiserator-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ spec:
kafka:
pool: nav-prod
env:
- name: JP_RETRY_ENABLED
value: "true"
- name: MQ_HOST_NAME
value: "mpls04.adeo.no"
- name: MQ_PORT
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/no/nav/syfo/Environment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ data class Environment(
val inputBackoutQueueName: String = getEnvVar("MQ_INPUT_BOQ_QUEUE_NAME"),
val dokArkivClientId: String = getEnvVar("DOKARKIV_CLIENT_ID"),
val dokArkivUrl: String = getEnvVar("DOK_ARKIV_URL"),
val jpRetryEnabled: Boolean = getEnvVar("JP_RETRY_ENABLED").toBoolean(),
val syfopdfgen: String = getEnvVar("PDF_GEN_URL"),
val arenaQueueName: String = getEnvVar("ARENA_OUTBOUND_QUEUENAME"),
val databaseHost: String = getEnvVar("NAIS_DATABASE_PADM2_PADM2_DB_HOST"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class DialogmeldingProcessor(
dokArkivClient = dokArkivClient,
pdfgenClient = pdfgenClient,
database = database,
jpRetryEnabled = env.jpRetryEnabled,
)
val signerendeLegeService = SignerendeLegeService(
syfohelsenettproxyClient = syfohelsenettproxyClient,
Expand Down
23 changes: 18 additions & 5 deletions src/main/kotlin/no/nav/syfo/services/JournalService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class JournalService(
private val dokArkivClient: DokArkivClient,
private val pdfgenClient: PdfgenClient,
private val database: DatabaseInterface,
private val jpRetryEnabled: Boolean = true,
) {
suspend fun onJournalRequest(
receivedDialogmelding: ReceivedDialogmelding,
Expand Down Expand Up @@ -50,19 +51,31 @@ class JournalService(
receivedDialogmelding.personNrPasient,
vedleggListe
)
val journalpost = dokArkivClient.createJournalpost(journalpostPayload, loggingMeta)

val journalpost = try {
dokArkivClient.createJournalpost(journalpostPayload, loggingMeta)
} catch (exc: Exception) {
if (jpRetryEnabled) {
throw exc
} else {
logger.error("Journalføring failed, skipping retry (should only happen in dev-gcp)", exc)
}
null
}
// Defaulting'en til "0" skal bare forekomme i dev-gcp:
// Har dette fordi vi ellers spammer ned dokarkiv med forsøk på å journalføre
// på personer som mangler aktør-id.
val journalpostId = journalpost?.journalpostId ?: "0"
MELDING_LAGER_I_JOARK.increment()
logger.info(
"Melding lagret i Joark med journalpostId {}, {}",
journalpost.journalpostId,
journalpostId,
StructuredArguments.fields(loggingMeta)
)
database.lagreJournalforing(
dialogmeldingid = receivedDialogmelding.dialogmelding.id,
journalpostId = journalpost.journalpostId,
journalpostId = journalpostId,
)
journalpost.journalpostId
journalpostId
} else {
journalpostId
}
Expand Down
1 change: 1 addition & 0 deletions src/test/kotlin/no/nav/syfo/TestEnvironment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ fun testEnvironment(
smgcpProxyUrl = smgcpUrl,
isbehandlerdialogClientId = "isbehandlerdialog",
isbehandlerdialogUrl = isbehandlerdialogUrl,
jpRetryEnabled = true,
)

fun testAppState() = ApplicationState(
Expand Down

0 comments on commit 570a4b6

Please sign in to comment.