Christoph Deppisch created CAMEL-23883:
------------------------------------------
Summary: Camel Kafka producer fails silently on unexpected message
body type
Key: CAMEL-23883
URL: https://issues.apache.org/jira/browse/CAMEL-23883
Project: Camel
Issue Type: Bug
Components: camel-kafka
Affects Versions: 4.21.0
Reporter: Christoph Deppisch
The Kafka message producer fails silently in
{code:java}
to("kafka:my-topic"){code}
when the Exchange message body has an unexpected type.
For instance when transforming the message body like in
{code:java}
transform().jq(".my-value"){code}
the result can be a message body of type
{_}*com.fasterxml.jackson.databind.node.IntNode*{_}{*}{*}
For some reason (I guess because of a missing Kafka serialization strategy) the
Kafka producer is not able to handle the message body type and the Camel route
fails silently to send the Kafka message. The Camel route does not report any
error in this situation and the Kafka event is just skipped without further
notice.
We should at least make sure to raise an exception here instead of failing
silently.
You can reproduce the behavior with this example project:
[https://github.com/citrusframework/citrus-quarkus-examples/blob/main/apache-camel/camel-mqtt]
A workaround that can be seen in this example project. The workaround is to
explicitly convert the _*com.fasterxml.jackson.databind.node.IntNode*_ message
body into a supported type such as Integer.class with
{code:java}
convertBodyTo(Integer.class){code}
With that the Kafka event is sent as expected.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)