Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-13878

Message is forwarded to the wrong Kafka Topic

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.24.1
    • 3.0.0.RC2, 3.0.0
    • camel-kafka
    • None
    • Unknown

    Description

      I have 3 Apache Spring Boot applications and 3 topics.

      Let's call them Topic A, B and C and the Spring Boot applications FirstApp, SecondApp and ThridApp. I use Java DSL for the Kafka configuration.

      The FirstApp creates a message to Kafka Topic A.

      The SecondApp reads from Topic A makes transformations and passes each value to Topic B.

      The ThirdApp reads from Topic B and after transformations tries to pass it to Topic C.

      At this point through the debugger I saw that at the class  org.apache.camel.component.kafka.KafkaProducer and at the method 

      protected Iterator<ProducerRecord> createRecorder(Exchange exchange) something strange is happening.
      The headerTopic (line 140) from the following line:

      String headerTopic = exchange.getIn().getHeader(KafkaConstants.TOPIC, String.class);

      contains the topic A! The correct topic that I have clearly set through the Java DSL can be found under the line 137: 

      String topic = endpoint.getConfiguration().getTopic();

      As a workaround I have entered the following line inside a processor at the SecondProgram:

      exchange.getIn().setHeader(KafkaConstants.TOPIC, null);

      This has the side-effect that the headerTopic at line 140 is empty and thus the correct topic from line 137 is used.

      I believe that since I have clearly set the destination topic at the ThirdProgram to Topic C then Apache Camel should not override this with Topic A.

      It looks like a bug since from the method description I understand that we try to avoid circular loops.

       

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            kklear Klearchos Klearchou
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: