我们向 Kafka 主题发送一条消息,该消息通过 Camel 路由发送到 ActiveMQ 主题,那里的一切都按预期工作。但现在我们有另一条路线将消息数组从 ActiveMQ 主题发送到 Kafka 的另一个主题,这就是 Camel 进入无限循环的地方。这是我的路线 XML。为什么这种类型的配置会导致无限循环?
<!--DEFINE KAFKA'S TOPCIS AS ENDPOINT-->
<endpoint id="tagBlink" uri="kafka:10.0.0.165:9092">
<property key="topic" value="tagBlink"/>
<property key="brokers" value="10.0.0.165:9092"/>
</endpoint>
<!--END OF KAFKA'S TOPICS's AS ENDPOINT-->
<endpoint id="testMike" uri="kafka:10.0.0.165:9092">
<property key="topic" value="testMike"/>
<property key="brokers" value="10.0.0.165:9092"/>
</endpoint>
<!-- Route from Kafka (otherMessage) to ActiveMQ (wherenet.flow.deliveryNotificationProducer)-->
<route id="route1">
<from uri="ref:tagBlink"/>
<!--<process ref="transformToXML" />-->
<to uri="activemq:topic:myTopic"/>
<log message="Routing message from Kafka"/>
</route>
<route id="routeAutoGeneratedAMQ">
<from uri="activemq:topic:myTopic" />
<to uri="ref:testMike"/>
<to uri="stream:out" />
</route>
最佳答案
经过一些测试,我在 Camel 配置中读取了这个参数
bridgeEndpoint Default:false Camel 2.16.0: If bridgeEndpoint is true, the producer will ignore the topic header setting of the message.
所以我尝试添加到我的端点
<!--DEFINE KAFKA'S TOPCIS AS ENDPOINT-->
<endpoint id="tagBlink" uri="kafka:10.0.0.165:9092">
<property key="topic" value="tagBlink"/>
<property key="topic" value="tagBlink"/>
<property key="brokers" value="10.0.0.165:9092"/>
<property key="bridgeEndpoint " value="true"/>
</endpoint>
<!--END OF KAFKA'S TOPICS's AS ENDPOINT-->
<endpoint id="testMike" uri="kafka:10.0.0.165:9092">
<property key="topic" value="testMike"/>
<property key="brokers" value="10.0.0.165:9092"/>
<property key="bridgeEndpoint " value="true"/>
</endpoint>
无限循环停止了。
关于java - 重新发送到 Kafka 主题时 Camel 中的无限循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51331915/