java - Camel Kafka:无法读取来自 Kafka 主题的消息
问题描述
我有一个 Kafka 集群(版本:0.10.1.0),有 9 个代理和 10 个分区。
我尝试使用 camel kafka 使用来自 java 应用程序的消息2.14.3
。这是我的 pom.xml
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-kafka</artifactId>
<version>2.14.3</version>
</dependency>
这只是我使用的与骆驼卡夫卡相关的依赖项。下面是骆驼卡夫卡消费者代码。
<route id="ReadFromTopic">
<from uri="kafka:[[topic]]?brokers=[[broker.list]]&groupId=[[consumer.group]]" />
<log message="read message : ${body}" />
</route>
我正在使用文档https://camel.apache.org/components/latest/kafka-component.html中指定的 Kafka URI 。
但下面是我在加载骆驼上下文时遇到的异常
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: kafka://[[topic]]?brokers=[[broker.list]]&groupId=[[consumer.group]] due to: Failed to resolve endpoint: kafka://[[topic]]?brokers=[[broker.list]]&groupId=[[consumer.group]] due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{brokers=[[broker.list]]}]
它说Unknown parameters=[{brokers=[[broker.list]]}]
。我试过了camel-kafka 3.x
,它消耗得很好。但我必须2.14.3
在生产中使用骆驼卡夫卡。我是否缺少任何依赖项或使用了错误的 URI?
解决方案
我认为您在第一个问题中走在正确的道路上。我很惊讶 Camel Kafka 的 URI 格式在 2.14.2 和较新版本的 Camel 2.x 之间发生了如此大的变化。也许是因为较新的 Kafka 版本?
您可以在2.24.3和2.14.3KafkaConfiguration
版本的文档中看到它。在 2.14.3 版本上,没有 getBrokers 方法来获取参数,所以你得到的错误信息是根据你使用的版本而定的。brokers
相反,在 2.24.3 版本中有这样的方法,因此它对应于较新的 Camel 2.x 版本的组件文档。
不幸的是,我没有找到 2.14.3 版本的组件文档,但也许您可以从您的第一个问题的 URI 中使用KafkaConfiguration
.
推荐阅读
- python - 我什么时候在 Mac 上使用了太多内存?
- android - Android Room @Query Insert Into getting Cannot access database on the main thread 因为它可能会长时间锁定 UI
- java - JavaFX 冻结窗口
- java - 使用词边界和 POS 将句子分割成固定大小的块
- javascript - Chart.js 动态数据集和堆叠条上的工具提示
- javascript - 模板文字除了反斜杠之外不起作用
- node.js - 由于 webpack 导致 ng 构建失败:UNMET PEER DEPENDENCY
- javascript - onKeyDown 在任何地方都被触发,而不仅仅是在一页上
- publish - Azure DevOps 将 .NET 桌面应用程序部署到本地计算机
- javascript - SVG Object classList.add() 将类添加到元素但不链接回样式表