Gajendran.G
Gajendran.G

Reputation: 21

How to configure multiple kafka consumer in application.yml file

Actually i have a springboot based micro-service , and i have used kafka to produce/consume data from different system. Now my question is i have two different topics and based on topics i have two different consumer classes to consume data,

how to define multiple consumer properties in application.yml file ?

I configured for one consumer in application.yml like below :-

spring:
    kafka:
         consumer:
            bootstrapservers: http://199.968.98.101:9092
            group-id: groupid-QA-02
            auto-offset-reset: latest
            key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
            value-deserializer: org.apache.kafka.common.serialization.StringDeserializer

I am using @KafkaListener in my consumer classes

example of consumer method which i used in code @KafkaListener(topics = "${app.topic.b2b_tf_ta_req}", groupId = "${app.topic.groupoId}") public void consume(String message) throws Exception {

}

Upvotes: 1

Views: 3870

Answers (1)

Dima Vidmich
Dima Vidmich

Reputation: 1375

As far as I know bootstrap-servers accept comma separated list of servers i.e. if you set it to server1:9092,server2:9092 kafka should connect to all of them

Upvotes: -1

Related Questions