Open ntkoopman opened 8 months ago
It should be considered as a deserialization failure. So definitely a bug.
Could you provide an example of such broken cloud events?
Any invalid JSON will do:
content-type: application/cloudevents+json
{"type":
An option is to use the io.quarkus.kafka.client.serialization.JsonObjectDeserializer
which would do the Json parsing on the Kafka client and the failure handler and failure strategy would work as expected.
Is there anything preventing you to use the JsonObject deserializer?
We may imagine a way to invoke the failure-strategy
but once you use the StringDeserializer it is not possible to catch this in the value-deserialization-failure-handler
.
Using JsonObjectDeserializer would make it impossible to handle binary messages on the same topic. Just to be clear, I don't need a work around, I got it working by using the CloudEvents SDK deserializer.
One side effect in Quarkus, is that it also triggers the liveness and readiness checks to fail, effectively causing a denial of service.
It still needs to be fixed in reactive messaging. The SDK is not very Quarkus friendly (native issues, detection, reflection...). It works, but may lead to issues.
When receiving a structured CloudEvent, the payload is converted to JSON by KafkaCloudEventHelper#createFromStructuredCloudEvent. If the actual data is not valid JSON, this throws an exception which is handled in KafkaSource by immediately closing the connection.
Both the
value-deserialization-failure-handler
andfailure-strategy
are never invoked, and since this is before any application code, it seems impossible to handle this failure case.