morganstanley / modern-cpp-kafka

A C++ API for Kafka clients (i.e. KafkaProducer, KafkaConsumer, AdminClient)
Apache License 2.0
348 stars 88 forks source link

how can subcribe multi topic using only one kafka::clients::KafkaConsumer and thread #178

Closed RyuShai closed 1 year ago

RyuShai commented 1 year ago

Can i subcribe multi topic using one kafka::clients::KafkaConsumer in single thread ?

kenneth-jia commented 1 year ago

You could subscribe multiple topics with a single KafkaConsumer, while underlying, each KafkaConsumer (or KafkaProducer) would have several internal threads (depending the number of brokers) ... The subscribe interface: https://github.com/morganstanley/modern-cpp-kafka/blob/main/include/kafka/KafkaConsumer.h#L70 There're also some testcases about the multiple-topics subscription, e.g. https://github.com/morganstanley/modern-cpp-kafka/blob/main/tests/integration/TestKafkaConsumer.cc#L1706