有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

重新发送卡夫卡主题时,在Camel中使用java无限循环

我们向Kafka主题发送一条消息,该主题通过驼峰路径发送到ActiveMQ主题,其中的所有内容都按预期工作。但现在我们有了另一条路径,将消息arraive从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>

共 (1) 个答案

  1. # 1 楼答案

    在一些测试之后,我在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>
    

    无限循环停止了