-
Bug
-
Resolution: Won't Do
-
Critical
-
None
-
4.4.GA
-
None
-
False
-
-
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
- Customer has a Kafka topic (input-topic) which receives messages from multiple sources, one of which is AMQ Broker
- 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&securityProtocol=SSL&sslTruststoreLocation={{kafka.ssl.truststore.location}}&sslTruststorePassword={{kafka.ssl.truststore.password}}"/>
<log message="Received event on WEP monitoring topic with headers: ${headers}" />
<choice>
<when>
<jsonpath>$[?(@.application != 'P20' && @.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>
-
- Messages "pulled" from the input-topic from Kafka are then relayed by passing through the TypeConverter , including its headers
- A number of JMS Headers are present which have as a value an integer (e.g.
JMSDeliveryMode: 2)- 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: " "]
-
-
- 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.