简体   繁体   中英

How to handle multiple kafka topics with springboot app?

I'm implementing RestFul api using spring boot application. Based on the requester, I need to pick the topic and get the data from that topic. Let say if I hit url requester1/data then I should get data from topic1 and if I hit the url requester2/data then I should get the data from topic2 and so on.

So how to handle these multiple topics in the spring boot app and get data from a particular topic when I get the request?

Well. you should inject a ConsumerFactory<?, ?> into your RESTFull service and use a KafkaConsumer API directly.

Any existing KafkaMessageListenerContainer architecture in the Spring Kafka is long-lived, event-driver implementation it can't be adjusted at runtime to perform consumption on demand. That's exactly for what KafkaConsumer exists.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM