java - Spring Kafka - All topics into the same consumer -
i'm trying consume multiple topics kafka using same @kafkalistener implementation, wanted have 1 consumer each topic (each 1 has 1 partition). in order achieve created @kafkalistener
with topicpattern="topic1|topic2|topic3"
, concurrentkafkalistenercontainerfactory concurrency 3 , groupid consumer_group
. problem topics assigned same consumer , other 2 consumers become idle following log shows:
21:49:13.140 [org.springframework.kafka.kafkalistenerendpointcontainer#0-1-c-1] info o.a.k.c.c.i.consumercoordinator - setting newly assigned partitions [] group consumer_group 21:49:13.140 [org.springframework.kafka.kafkalistenerendpointcontainer#0-2-c-1] info o.a.k.c.c.i.consumercoordinator - setting newly assigned partitions [] group consumer_group 21:49:13.141 [org.springframework.kafka.kafkalistenerendpointcontainer#0-0-c-1] info o.a.k.c.c.i.consumercoordinator - setting newly assigned partitions [topic1, topic2, topic3] group consumer_group
how can hint spring kafka spread each topic different consumer?
cheers
use different groupid per consumer. since 3 of consumers in same group divide partitions amongst topic. since each topic has 1 partition 1 consumer can assigned.
also not include each topic in subscribe call, 1 want in each consumer.
read more on kafkas website. cover pretty clearly.
alternative: keep same group id make each consumer subsribe topic wants only
Comments
Post a Comment