Skip to content

Commit

Permalink
test commit
Browse files Browse the repository at this point in the history
  • Loading branch information
xcodeassociated committed Sep 17, 2024
1 parent 896447f commit 4dcdb13
Showing 1 changed file with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import org.apache.kafka.clients.consumer.ConsumerConfig
import org.apache.kafka.clients.producer.ProducerConfig
import org.apache.kafka.common.serialization.StringDeserializer
import org.apache.kafka.common.serialization.StringSerializer
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Profile
Expand All @@ -25,12 +24,6 @@ import org.springframework.kafka.support.serializer.JsonSerializer
@EnableKafka
class KafkaConfig {

@Value("\${spring.kafka.bootstrap-servers}")
private lateinit var bootstrapServer: String

@Value("\${spring.kafka.consumer.group-id}")
private lateinit var groupId: String

@Bean
fun kafkaListenerContainerFactory(consumerFactory: ConsumerFactory<String, JsonNode>) =
ConcurrentKafkaListenerContainerFactory<String, JsonNode>().also { it.consumerFactory = consumerFactory }
Expand All @@ -39,8 +32,9 @@ class KafkaConfig {
fun consumerFactory() = DefaultKafkaConsumerFactory<String, JsonNode>(consumerProps)

val consumerProps = mapOf(
ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG to bootstrapServer,
ConsumerConfig.GROUP_ID_CONFIG to groupId,
// todo: change it
ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG to "kafka-broker:9094",
ConsumerConfig.GROUP_ID_CONFIG to "sample-group-jvm-jpa",
ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG to StringDeserializer::class.java,
ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG to JsonDeserializer::class.java,
JsonDeserializer.USE_TYPE_INFO_HEADERS to false,
Expand All @@ -53,7 +47,8 @@ class KafkaConfig {
fun producerFactory() = DefaultKafkaProducerFactory<String, KafkaMessage>(senderProps)

val senderProps = mapOf(
ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG to bootstrapServer,
// todo: change it
ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG to "kafka-broker:9094",
ProducerConfig.LINGER_MS_CONFIG to 10,
ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG to StringSerializer::class.java,
ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG to JsonSerializer::class.java
Expand Down

0 comments on commit 4dcdb13

Please sign in to comment.