@@ -6,7 +6,6 @@ import org.apache.kafka.clients.consumer.ConsumerConfig
6
6
import org.apache.kafka.clients.producer.ProducerConfig
7
7
import org.apache.kafka.common.serialization.StringDeserializer
8
8
import org.apache.kafka.common.serialization.StringSerializer
9
- import org.springframework.beans.factory.annotation.Value
10
9
import org.springframework.context.annotation.Bean
11
10
import org.springframework.context.annotation.Configuration
12
11
import org.springframework.context.annotation.Profile
@@ -25,12 +24,6 @@ import org.springframework.kafka.support.serializer.JsonSerializer
25
24
@EnableKafka
26
25
class KafkaConfig {
27
26
28
- @Value(" \$ {spring.kafka.bootstrap-servers}" )
29
- private lateinit var bootstrapServer: String
30
-
31
- @Value(" \$ {spring.kafka.consumer.group-id}" )
32
- private lateinit var groupId: String
33
-
34
27
@Bean
35
28
fun kafkaListenerContainerFactory (consumerFactory : ConsumerFactory <String , JsonNode >) =
36
29
ConcurrentKafkaListenerContainerFactory <String , JsonNode >().also { it.consumerFactory = consumerFactory }
@@ -39,8 +32,9 @@ class KafkaConfig {
39
32
fun consumerFactory () = DefaultKafkaConsumerFactory <String , JsonNode >(consumerProps)
40
33
41
34
val consumerProps = mapOf (
42
- ConsumerConfig .BOOTSTRAP_SERVERS_CONFIG to bootstrapServer,
43
- ConsumerConfig .GROUP_ID_CONFIG to groupId,
35
+ // todo: change it
36
+ ConsumerConfig .BOOTSTRAP_SERVERS_CONFIG to " kafka-broker:9094" ,
37
+ ConsumerConfig .GROUP_ID_CONFIG to " sample-group-jvm-jpa" ,
44
38
ConsumerConfig .KEY_DESERIALIZER_CLASS_CONFIG to StringDeserializer ::class .java,
45
39
ConsumerConfig .VALUE_DESERIALIZER_CLASS_CONFIG to JsonDeserializer ::class .java,
46
40
JsonDeserializer .USE_TYPE_INFO_HEADERS to false ,
@@ -53,7 +47,8 @@ class KafkaConfig {
53
47
fun producerFactory () = DefaultKafkaProducerFactory <String , KafkaMessage >(senderProps)
54
48
55
49
val senderProps = mapOf (
56
- ConsumerConfig .BOOTSTRAP_SERVERS_CONFIG to bootstrapServer,
50
+ // todo: change it
51
+ ConsumerConfig .BOOTSTRAP_SERVERS_CONFIG to " kafka-broker:9094" ,
57
52
ProducerConfig .LINGER_MS_CONFIG to 10 ,
58
53
ProducerConfig .KEY_SERIALIZER_CLASS_CONFIG to StringSerializer ::class .java,
59
54
ProducerConfig .VALUE_SERIALIZER_CLASS_CONFIG to JsonSerializer ::class .java
0 commit comments