gpt4 book ai didi

java - Camel 卡夫卡 : Unable to read messages from Kafka topic

转载 作者:行者123 更新时间:2023-12-01 16:15:23 24 4
gpt4 key购买 nike

我有一个 Kafka 集群(版本:0.10.1.0),有 9 个代理和 10 个分区。

我尝试使用camel kafka 2.14.3使用来自java应用程序的消息。这是我的 pom.xml

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-kafka</artifactId>
<version>2.14.3</version>
</dependency>

这只是我使用的与 Camel 卡夫卡相关的唯一依赖项。下面是camel kafka消费者代码。

<route id="ReadFromTopic">
<from uri="kafka:[[topic]]?brokers=[[broker.list]]&amp;groupId=[[consumer.group]]" />
<log message="read message : ${body}" />
</route>

我正在使用文档 https://camel.apache.org/components/latest/kafka-component.html 中指定的 Kafka URI 。

但下面是我在加载 Camel 上下文时遇到的异常

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]]}]

上面写着未知参数=[{brokers=[[broker.list]]}]。我尝试使用camel-kafka 3.x,它消耗得很好。但我必须在生产中使用camel kafka 2.14.3。我是否缺少任何依赖项或使用了错误的 URI?

最佳答案

我认为您在 your first question 中走在正确的道路上。我非常惊讶 Camel Kafka 的 URI 格式在 2.14.2 和较新版本的 Camel 2.x 之间发生了如此大的变化。也许是因为新的 Kafka 版本?

您可以在version 2.24.3KafkaConfiguration文档中看到它和 version 2.14.3 。在版本 2.14.3 上,没有 getBrokers 方法来获取 brokers 参数,因此您收到的错误消息取决于您使用的版本。

相比之下,在2.24.3版本上有这样的方法,因此它对应于component documentation较新的 Camel 2.x 版本。

不幸的是,我没有找到版本 2.14.3 的组件文档,但也许您可以使用 KafkaConfiguration 的可能参数从第一个问题的 URI 构建它。

关于java - Camel 卡夫卡 : Unable to read messages from Kafka topic,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62408693/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com