问题描述
我已经用Java语言在play框架中搜索了数千个站点,以查找kafka消费者示例.但是找不到任何例子.谁能提供有关如何编写一项服务的详细信息,该服务会连续使用kafka产生的主题.
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.
谢谢
推荐答案
播放是一个网络框架.基本的Actor系统依赖Akka.
Play is a web-framework. The underlying Actor system relies on Akka.
Akka Kafka API 称为Alpakka ,因此我怀疑您在搜索错误的关键字
The Akka Kafka API is called Alpakka, so I suspect you are searching in the wrong keywords
要结合Akka和带Kafka的Play,甚至可以使用 Lagom框架
To combine both Akka and Play w/ Kafka, you can even use the Lagom Framework
否则,当然,无论Play框架如何,您都可以使用普通的Java使用者
Otherwise, of course you can use plain Java consumer as well, regardless of Play Framework
KafkaConsumer c = new KafkaConsumer(props);
while (true) {
ConsumerRecords r = c.poll(1000);
...
}
这篇关于Kafka Consumer在使用Java的Play框架中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!