-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added kafka-consumer for oppgavehendelse, and updating db
- Loading branch information
1 parent
8160c81
commit 2a971f1
Showing
14 changed files
with
268 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package no.nav.syfo.aksessering | ||
|
||
import no.nav.syfo.model.ManuellOppgaveStatus | ||
import java.time.LocalDateTime | ||
|
||
data class UlosteOppgave( | ||
val oppgaveId: Int, | ||
val mottattDato: LocalDateTime, | ||
val status: ManuellOppgaveStatus? = null, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,51 @@ | ||
package no.nav.syfo.clients | ||
|
||
import com.fasterxml.jackson.databind.DeserializationFeature | ||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule | ||
import com.fasterxml.jackson.module.kotlin.registerKotlinModule | ||
import no.nav.syfo.Environment | ||
import no.nav.syfo.kafka.aiven.KafkaUtils | ||
import no.nav.syfo.kafka.toConsumerConfig | ||
import no.nav.syfo.oppgave.kafka.OppgaveKafkaAivenRecord | ||
import org.apache.kafka.clients.consumer.ConsumerConfig | ||
import org.apache.kafka.clients.consumer.KafkaConsumer | ||
import org.apache.kafka.common.serialization.Deserializer | ||
import org.apache.kafka.common.serialization.StringDeserializer | ||
|
||
class KafkaOppgaveDeserializer : Deserializer<OppgaveKafkaAivenRecord> { | ||
private val objectMapper = ObjectMapper() | ||
.registerModule(JavaTimeModule()) | ||
.registerKotlinModule() | ||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) | ||
|
||
override fun deserialize(topic: String, bytes: ByteArray): OppgaveKafkaAivenRecord { | ||
return objectMapper.readValue(bytes, OppgaveKafkaAivenRecord::class.java) | ||
} | ||
} | ||
class KafkaConsumers(env: Environment) { | ||
private val consumerPropertiesAiven = KafkaUtils.getAivenKafkaConfig().also { | ||
it.let { | ||
it[ConsumerConfig.MAX_POLL_RECORDS_CONFIG] = "1" | ||
it[ConsumerConfig.AUTO_OFFSET_RESET_CONFIG] = "none" | ||
} | ||
}.toConsumerConfig( | ||
"${env.applicationName}-consumer", | ||
valueDeserializer = StringDeserializer::class, | ||
val kafkaAivenConsumerManuellOppgave = KafkaConsumer<String, String>( | ||
KafkaUtils.getAivenKafkaConfig().also { | ||
it.let { | ||
it[ConsumerConfig.MAX_POLL_RECORDS_CONFIG] = "1" | ||
it[ConsumerConfig.AUTO_OFFSET_RESET_CONFIG] = "none" | ||
} | ||
}.toConsumerConfig( | ||
"${env.applicationName}-consumer", | ||
valueDeserializer = StringDeserializer::class, | ||
), | ||
) | ||
val oppgaveHendelseConsumer = KafkaConsumer( | ||
KafkaUtils.getAivenKafkaConfig() | ||
.also { | ||
it[ConsumerConfig.AUTO_OFFSET_RESET_CONFIG] = "earliest" | ||
it[ConsumerConfig.MAX_POLL_RECORDS_CONFIG] = 50 | ||
} | ||
.toConsumerConfig( | ||
"${env.applicationName}-consumer", | ||
KafkaOppgaveDeserializer::class, | ||
), | ||
StringDeserializer(), | ||
KafkaOppgaveDeserializer(), | ||
) | ||
|
||
val kafkaAivenConsumerManuellOppgave = KafkaConsumer<String, String>(consumerPropertiesAiven) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.