diff --git a/build.gradle.kts b/build.gradle.kts index f8338ccd..8d5dbfec 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -41,7 +41,7 @@ object Versions { plugins { java - kotlin("jvm") version "1.9.0" + kotlin("jvm") version "1.9.20" id("com.github.johnrengelman.shadow") version "8.1.1" id("org.jlleitschuh.gradle.ktlint") version "11.4.2" } diff --git a/src/main/kotlin/no/nav/syfo/application/SendDialogmeldingArenaAdhocCronjob.kt b/src/main/kotlin/no/nav/syfo/application/SendDialogmeldingArenaAdhocCronjob.kt deleted file mode 100644 index 23c0b83f..00000000 --- a/src/main/kotlin/no/nav/syfo/application/SendDialogmeldingArenaAdhocCronjob.kt +++ /dev/null @@ -1,62 +0,0 @@ -package no.nav.syfo.application - -import net.logstash.logback.argument.StructuredArguments -import no.nav.syfo.application.cronjob.Cronjob -import no.nav.syfo.application.cronjob.CronjobResult -import no.nav.syfo.db.DatabaseInterface -import no.nav.syfo.model.ReceivedDialogmelding -import no.nav.syfo.persistering.db.getAdhocArenaMeldinger -import no.nav.syfo.persistering.db.lagreSendtArena -import no.nav.syfo.services.ArenaDialogmeldingService -import no.nav.syfo.util.safeUnmarshal -import org.slf4j.LoggerFactory - -class SendDialogmeldingArenaAdhocCronjob( - private val database: DatabaseInterface, - private val arenaDialogmeldingService: ArenaDialogmeldingService, -) : Cronjob { - override val initialDelayMinutes: Long = 3 - override val intervalDelayMinutes: Long = 1000 - - override suspend fun run() { - val result = runJob() - log.info( - "Completed sending dialogmelding from adhoc list to arena with result: {}, {}", - StructuredArguments.keyValue("failed", result.failed), - StructuredArguments.keyValue("updated", result.updated), - ) - } - - suspend fun runJob(): CronjobResult { - val result = CronjobResult() - val adhocArenaMeldinger = database.getAdhocArenaMeldinger() - adhocArenaMeldinger.forEach { (dialogmeldingId, fellesformat, msgId) -> - try { - val fellesformatXml = safeUnmarshal(fellesformat) - val receivedDialogmelding = ReceivedDialogmelding.create( - dialogmeldingId = dialogmeldingId, - fellesformat = fellesformatXml, - inputMessageText = fellesformat, - ) - arenaDialogmeldingService.sendArenaDialogmeldingToMQ( - receivedDialogmelding = receivedDialogmelding, - fellesformatXml = fellesformatXml - ) - database.lagreSendtArena( - dialogmeldingid = dialogmeldingId, - isSent = true, - ) - result.updated++ - } catch (e: Exception) { - log.error("Caught exception in ad hoc sending dialogmelding to arena", e) - result.failed++ - } - } - - return result - } - - companion object { - private val log = LoggerFactory.getLogger(SendDialogmeldingArenaAdhocCronjob::class.java) - } -} diff --git a/src/main/kotlin/no/nav/syfo/application/cronjob/CronjobLauncher.kt b/src/main/kotlin/no/nav/syfo/application/cronjob/CronjobLauncher.kt index 87251006..0e19508e 100644 --- a/src/main/kotlin/no/nav/syfo/application/cronjob/CronjobLauncher.kt +++ b/src/main/kotlin/no/nav/syfo/application/cronjob/CronjobLauncher.kt @@ -30,12 +30,6 @@ fun launchCronjobs( ) allCronjobs.add(sendDialogmeldingArenaCronjob) } - // TODO: Remove after it has run once in prod - val sendDialogmeldingArenaAdhocCronjob = SendDialogmeldingArenaAdhocCronjob( - database = database, - arenaDialogmeldingService = arenaDialogmeldingService, - ) - allCronjobs.add(sendDialogmeldingArenaAdhocCronjob) allCronjobs.forEach { launchBackgroundTask(applicationState) {