Uploaded image for project: 'Red Hat build of Apache Camel'
  1. Red Hat build of Apache Camel
  2. RHBAC-11

Type Conversion Error from byte[] to Long in Camel 4 from Kafka Topic for JMS* headers

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Critical Critical
    • None
    • 4.4.GA
    • Camel for Spring Boot
    • None
    • False
    • Hide

      None

      Show
      None
    • False
    • Critical

      ENVIRONMENT

      • Java 17
      • Camel 4
      • Spring Boot
      • Kafka
      • AMQ Broker / IBM MQ 

      Customer is migrating from Camel 2 to Camel 4 and encountering a type conversion issue when messages are sent from Kafka to IBM MQ. The system throws a TypeConversionException for converting byte[] to Long. The error occurs specifically when the system attempts to handle messages with JMS headers that are not properly converted. Please note that this behavior was not present in Camel 2 (Fuse)

       

      STEPS TO REPRODUCE

      1. Customer has a Kafka topic (input-topic) which receives messages from multiple sources, one of which is AMQ Broker
      2. Messages from the Kafka topic are then relayed to an IBM MQ broker (though the type of broker seem to be irrelevant as the problem is present also with AMQ Broker as a destination) using a Camel Route
          <from uri="kafka:input-topic?brokers=my-cluster-kafka-listener1-bootstrap-amq-streams.apps.dscrimieocp4.vmware.tamlab.rdu2.redhat.com:443&amp;securityProtocol=SSL&amp;sslTruststoreLocation={{kafka.ssl.truststore.location}}&amp;sslTruststorePassword={{kafka.ssl.truststore.password}}"/>
                <log message="Received event on WEP monitoring topic with headers: ${headers}" />
                <choice>
                   <when>
                      <jsonpath>$[?(@.application != 'P20' &amp;&amp; @.application != 'p20')]</jsonpath>
                      <log message="Sending WEP monitoring event to BMA: ${body}"/>
                      <setHeader name="JMSDeliveryMode">
                         <constant>2</constant>
                      </setHeader>
                      <to uri="activemq:queue:TEST"/>
      
                      <!-- <to uri="wepaymq:queue:DE.QQ.WEP.BMA.WEPMONITORING"/> -->
                   </when>
                </choice>
             </route> 
        1. Messages "pulled" from the input-topic from Kafka are then relayed by passing through the TypeConverter , including its headers
        2. A number of JMS Headers are present which have as a value an integer (e.g. 
          JMSDeliveryMode: 2)
          1. This causes a NumberFormatException 

      2024-04-15T09:13:10.967+02:00 WARN 11202 — [er[input-topic]] o.a.camel.component.kafka.KafkaConsumer : Error during processing. Exchange[338A3D7ADE63460-0000000000000000]. Caused by: [org.apache.camel.TypeConversionException - Error during type conversion from type: byte[] to the required type: java.lang.Long with value [B@218c3d49 due to java.lang.NumberFormatException: For input string: " "]

          1. However if the headers have a value with a String representation then there is no problem (e.g. JMSDeliveryMode: "2")

      IMPACT

      Because of this problem Customer cannot migrate from Camel 2 (Fuse) to Camel 4. Dozens of apps put messages on that Kafka topic and this adjustment would require a massive rework. Moreover this behavior was not present in Camel 2.
       

              gmalinko Georgi Malinkov
              dscrimie84 Davide Scrimieri
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: