Skip to content
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

Enable cronjob after TLS turned on in MQ #241

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

Applikasjon for håndtering av dialogmeldinger i SYFO-domenet. Funksjonalitet:

* Deling av oppfølgingsplan
* Deling av oppfølgingsplan
* Sending av dialogmøterelaterte dialogmeldinger
* Sending av andre dialogmeldinger
* API med informasjon om behandlere (fastlege) som kan motta dialogmelding

## Technologies used
Expand Down Expand Up @@ -95,6 +97,17 @@ This application owns and consumes from the following topic:

* isdialogmelding-behandler-dialogmelding-bestilling

### MQ config

This application uses an encrypted channel when reading av sending messages to MQ. The certificate and password for
the jks-file can be found in Fasit. The resources must be stored in GCP as secrets:

`kubectl create secret generic isdialogmelding-keystore-pwd --from-literal MQ_KEYSTORE_PASSWORD=xxxxxxxx`

and

`kubectl create secret generic isdialogmelding-keystore --from-file isdialogmelding-keystore.jks=./srvisdialogmelding_p.jks`

## Contact

### For NAV employees
Expand Down
9 changes: 5 additions & 4 deletions src/main/kotlin/no/nav/syfo/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import no.nav.syfo.client.pdl.PdlClient
import no.nav.syfo.client.veiledertilgang.VeilederTilgangskontrollClient
import no.nav.syfo.cronjob.cronjobModule
import no.nav.syfo.dialogmelding.DialogmeldingService
import no.nav.syfo.dialogmelding.apprec.ApprecService
import no.nav.syfo.dialogmelding.apprec.consumer.ApprecConsumer
import no.nav.syfo.dialogmelding.status.DialogmeldingStatusService
import no.nav.syfo.dialogmelding.status.kafka.*
import no.nav.syfo.identhendelse.IdenthendelseService
Expand All @@ -30,6 +32,7 @@ import no.nav.syfo.identhendelse.kafka.launchKafkaTaskIdenthendelse
import org.apache.kafka.clients.producer.KafkaProducer
import org.slf4j.LoggerFactory
import java.util.concurrent.TimeUnit
import javax.jms.Session

const val applicationPort = 8080

Expand All @@ -41,7 +44,7 @@ fun main() {
val logger = LoggerFactory.getLogger("ktor.application")
val environment = Environment()
setMQTlsProperties(environment)
// val mqSender = MQSender(environment)
val mqSender = MQSender(environment)
val wellKnownInternalAzureAD = getWellKnown(environment.azureAppWellKnownUrl)
val wellKnownInternalIdportenTokenX = getWellKnown(environment.idportenTokenXWellKnownUrl)
val azureAdClient = AzureAdClient(
Expand Down Expand Up @@ -128,7 +131,7 @@ fun main() {
)
val dialogmeldingService = DialogmeldingService(
pdlClient = pdlClient,
// mqSender = mqSender,
mqSender = mqSender,
)
cronjobModule(
applicationState = applicationState,
Expand All @@ -147,7 +150,6 @@ fun main() {
applicationEnvironmentKafka = environment.kafka,
database = applicationDatabase,
)
/*
launchBackgroundTask(
applicationState = applicationState,
) {
Expand All @@ -173,7 +175,6 @@ fun main() {
blockingApplicationRunner.run()
}
}
*/
val identhendelseService = IdenthendelseService(
database = applicationDatabase,
pdlClient = pdlClient,
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/no/nav/syfo/application/mq/MQUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ fun connectionFactory(env: Environment): ConnectionFactory {
setStringProperty(CommonConstants.PASSWORD, env.serviceuserPassword)
}
}

fun Session.consumerForQueue(queueName: String): MessageConsumer = createConsumer(createQueue(queueName))
5 changes: 1 addition & 4 deletions src/main/kotlin/no/nav/syfo/cronjob/CronjobModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,15 @@ fun cronjobModule(
applicationState = applicationState,
leaderPodClient = leaderPodClient,
)
/*
val dialogmeldingSendCronjob = DialogmeldingSendCronjob(
dialogmeldingToBehandlerService = dialogmeldingToBehandlerService,
dialogmeldingService = dialogmeldingService,
dialogmeldingStatusService = dialogmeldingStatusService,
)
*/
val dialogmeldingStatusCronjob =
DialogmeldingStatusCronjob(dialogmeldingStatusService = dialogmeldingStatusService)

// listOf(dialogmeldingSendCronjob, dialogmeldingStatusCronjob).forEach {
listOf(dialogmeldingStatusCronjob).forEach {
listOf(dialogmeldingSendCronjob, dialogmeldingStatusCronjob).forEach {
launchBackgroundTask(
applicationState = applicationState,
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package no.nav.syfo.dialogmelding

import no.nav.syfo.application.mq.MQSender
import no.nav.syfo.behandler.domain.*
import no.nav.syfo.client.pdl.PdlClient
import no.nav.syfo.dialogmelding.bestilling.domain.DialogmeldingToBehandlerBestilling
Expand All @@ -14,13 +15,13 @@ private val log = LoggerFactory.getLogger("no.nav.syfo.dialogmelding")

class DialogmeldingService(
val pdlClient: PdlClient,
// val mqSender: MQSender,
val mqSender: MQSender,
) {
suspend fun sendMelding(melding: DialogmeldingToBehandlerBestilling) {
log.info("Sending dialogmelding med type ${melding.type} to behandler with partnerId: ${melding.behandler.kontor.partnerId}")
val arbeidstaker = getArbeidstaker(melding.arbeidstakerPersonident)
val fellesformat: Fellesformat = opprettDialogmelding(melding, arbeidstaker)
// mqSender.sendMessageToEmottak(fellesformat.message!!)
mqSender.sendMessageToEmottak(fellesformat.message!!)
}

private suspend fun getArbeidstaker(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class DialogmeldingCronjobSpek : Spek({
)
val dialogmeldingService = DialogmeldingService(
pdlClient = pdlClient,
// mqSender = mqSenderMock,
mqSender = mqSenderMock,
)
val dialogmeldingSendCronjob = DialogmeldingSendCronjob(
dialogmeldingToBehandlerService = dialogmeldingToBehandlerService,
Expand All @@ -80,7 +80,7 @@ class DialogmeldingCronjobSpek : Spek({
}

describe("Cronjob sender bestilte dialogmeldinger") {
xit("Sender bestilt dialogmelding") {
it("Sender bestilt dialogmelding") {
val behandlerRef = UUID.randomUUID()
val partnerId = PartnerId(random.nextInt())
val behandler = generateBehandler(behandlerRef, partnerId)
Expand Down Expand Up @@ -127,7 +127,7 @@ class DialogmeldingCronjobSpek : Spek({
}
verify(exactly = 0) { mqSenderMock.sendMessageToEmottak(any()) }
}
xit("Sender bestilt dialogmelding uten relasjon mellom arbeidstaker og behandler") {
it("Sender bestilt dialogmelding uten relasjon mellom arbeidstaker og behandler") {
val behandlerRef = UUID.randomUUID()
val partnerId = PartnerId(random.nextInt())
val behandler = generateBehandler(behandlerRef, partnerId)
Expand Down Expand Up @@ -167,7 +167,7 @@ class DialogmeldingCronjobSpek : Spek({
pBehandlerDialogmeldingBestillingAfter!!.sendt shouldNotBeEqualTo null
pBehandlerDialogmeldingBestillingAfter.sendtTries shouldBeEqualTo 1
}
xit("Sender bestilt oppfølgingsplan") {
it("Sender bestilt oppfølgingsplan") {
clearAllMocks()
val messageSlot = slot<String>()
justRun { mqSenderMock.sendMessageToEmottak(capture(messageSlot)) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object DialogmeldingServiceSpek : Spek({

val dialogmeldingService = DialogmeldingService(
pdlClient = pdlClient,
// mqSender = mqSender,
mqSender = mqSender,
)

val arbeidstakerPersonident = Personident("01010112345")
Expand Down Expand Up @@ -67,7 +67,7 @@ object DialogmeldingServiceSpek : Spek({
database.dropData()
}
describe("DialogmeldingService") {
xit("Sends correct message on MQ when foresporsel dialogmote-innkalling") {
it("Sends correct message on MQ when foresporsel dialogmote-innkalling") {
val messageSlot = slot<String>()
justRun { mqSender.sendMessageToEmottak(capture(messageSlot)) }

Expand All @@ -91,7 +91,7 @@ object DialogmeldingServiceSpek : Spek({
expectedFellesformatMessageAsRegex.matches(actualFellesformatMessage),
)
}
xit("Sends correct message on MQ when foresporsel dialogmote-innkalling for behandler and arbeidstaker with dnr") {
it("Sends correct message on MQ when foresporsel dialogmote-innkalling for behandler and arbeidstaker with dnr") {
clearAllMocks()
val messageSlot = slot<String>()
justRun { mqSender.sendMessageToEmottak(capture(messageSlot)) }
Expand All @@ -116,7 +116,7 @@ object DialogmeldingServiceSpek : Spek({
expectedFellesformatMessageAsRegex.matches(actualFellesformatMessage),
)
}
xit("Sends correct message on MQ when foresporsel dialogmote-innkalling to behandler without orgnr") {
it("Sends correct message on MQ when foresporsel dialogmote-innkalling to behandler without orgnr") {
clearAllMocks()
val messageSlot = slot<String>()
justRun { mqSender.sendMessageToEmottak(capture(messageSlot)) }
Expand All @@ -134,7 +134,7 @@ object DialogmeldingServiceSpek : Spek({
}
verify(exactly = 1) { mqSender.sendMessageToEmottak(any()) }
}
xit("Sends correct message on MQ when foresporsel endre tid-sted") {
it("Sends correct message on MQ when foresporsel endre tid-sted") {
clearAllMocks()
val messageSlot = slot<String>()
justRun { mqSender.sendMessageToEmottak(capture(messageSlot)) }
Expand All @@ -159,7 +159,7 @@ object DialogmeldingServiceSpek : Spek({
expectedFellesformatMessageAsRegex.matches(actualFellesformatMessage),
)
}
xit("Sends correct message on MQ when referat") {
it("Sends correct message on MQ when referat") {
clearAllMocks()
val messageSlot = slot<String>()
justRun { mqSender.sendMessageToEmottak(capture(messageSlot)) }
Expand All @@ -184,7 +184,7 @@ object DialogmeldingServiceSpek : Spek({
expectedFellesformatMessageAsRegex.matches(actualFellesformatMessage),
)
}
xit("Sends correct message on MQ when avlysning") {
it("Sends correct message on MQ when avlysning") {
clearAllMocks()
val messageSlot = slot<String>()
justRun { mqSender.sendMessageToEmottak(capture(messageSlot)) }
Expand All @@ -209,7 +209,7 @@ object DialogmeldingServiceSpek : Spek({
expectedFellesformatMessageAsRegex.matches(actualFellesformatMessage),
)
}
xit("Sends correct message on MQ when foresporsel") {
it("Sends correct message on MQ when foresporsel") {
clearAllMocks()
val messageSlot = slot<String>()
justRun { mqSender.sendMessageToEmottak(capture(messageSlot)) }
Expand All @@ -233,7 +233,7 @@ object DialogmeldingServiceSpek : Spek({
expectedFellesformatMessageAsRegex.matches(actualFellesformatMessage),
)
}
xit("Sends correct message on MQ when purring foresporsel") {
it("Sends correct message on MQ when purring foresporsel") {
clearAllMocks()
val messageSlot = slot<String>()
justRun { mqSender.sendMessageToEmottak(capture(messageSlot)) }
Expand All @@ -257,7 +257,7 @@ object DialogmeldingServiceSpek : Spek({
expectedFellesformatMessageAsRegex.matches(actualFellesformatMessage),
)
}
xit("Sends correct message on MQ when foresporsel om legeerklæring") {
it("Sends correct message on MQ when foresporsel om legeerklæring") {
clearAllMocks()
val messageSlot = slot<String>()
justRun { mqSender.sendMessageToEmottak(capture(messageSlot)) }
Expand All @@ -281,7 +281,7 @@ object DialogmeldingServiceSpek : Spek({
expectedFellesformatMessageAsRegex.matches(actualFellesformatMessage),
)
}
xit("Sends correct message on MQ when retur av legeerklæring") {
it("Sends correct message on MQ when retur av legeerklæring") {
clearAllMocks()
val messageSlot = slot<String>()
justRun { mqSender.sendMessageToEmottak(capture(messageSlot)) }
Expand All @@ -305,7 +305,7 @@ object DialogmeldingServiceSpek : Spek({
expectedFellesformatMessageAsRegex.matches(actualFellesformatMessage),
)
}
xit("Sends correct message on MQ when melding fra NAV") {
it("Sends correct message on MQ when melding fra NAV") {
clearAllMocks()
val messageSlot = slot<String>()
justRun { mqSender.sendMessageToEmottak(capture(messageSlot)) }
Expand Down