问题
I have searched thousands of sites for kafka consumer example in play framework in java language. But not able to find any example. Can anyone provide details on how to write a service which consumes topics produced by kafka continuously.
Thanks
回答1:
Play is a web-framework. The underlying Actor system relies on Akka.
The Akka Kafka API is called Alpakka, so I suspect you are searching in the wrong keywords
To combine both Akka and Play w/ Kafka, you can even use the Lagom Framework
Otherwise, of course you can use plain Java consumer as well, regardless of Play Framework
provide details on how to write a service which consumes topics produced by kafka continuously
KafkaConsumer c = new KafkaConsumer(props);
while (true) {
ConsumerRecords r = c.poll(1000);
...
}
来源:https://stackoverflow.com/questions/60045171/kafka-consumer-in-play-framework-using-java