Apache Kafka 是否提供异步订阅回调 API? [英] Does Apache Kafka provide an asynchronous subscription callback API?

查看:24
本文介绍了Apache Kafka 是否提供异步订阅回调 API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目将 Apache Kafka 视为一种潜在的替代基于 JMS 的陈旧消息传递方法.为了让这个过渡尽可能顺利,如果替换队列系统(Kafka)有一个异步订阅机制,类似于我们当前项目的使用 MessageListenerMessageConsumer 订阅主题并接收异步通知.如果 Kafka 不严格遵守 JMS API,我不太在意,但相反,如果我不需要,我宁愿不重新设计我们的整个发布-订阅-通知类套件.

My project is looking at Apache Kafka as a potential replacement for an aging JMS-based messaging approach. In order to make this transition as smooth as possible, it would be ideal if the replacement queuing system (Kafka) had an asynchronous subscription mechanism, similar to our current project's JMS mechanism of using MessageListener and MessageConsumer to subscribe to topics and receive asynchronous notifications. I don't care so much if Kafka doesn't strictly conform to the JMS API, but conversely, I would prefer not to redesign our entire suite of publish-subscribe-notification classes if I don't need to.

我可以找到各种KafkaConsumer 轮询 示例,但到目前为止还没有找到任何通过异步通知向客户端通知新消息的示例.

I can find all kinds of KafkaConsumer polling examples, but so far have not been able to find any examples with a client being notified of new messages via asynchronous notification.

有谁知道当前版本的 Kafka(截至本文发布时为 0.10.2)是否提供了这样的 API,或者我是否一直在尝试使用轮询重写我的遗留代码?

Does anyone know if the current version of Kafka (0.10.2 as of the time of this post) provides such an API, or am I stuck with trying to rewrite my legacy code using polling?

推荐答案

Kafka 客户端仅提供按需池机制,但您可以使用 spring-kafka.它提供了 MessageListener 接口和 KafkaListener 注释等.请参阅文档一>.

Kafka clients provides only on-demand pooling mechanism but you can use spring-kafka. It provides MessageListener interface and KafkaListener annotation and similar. See documentation.

这篇关于Apache Kafka 是否提供异步订阅回调 API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆