Event type routing and deserialization issues (#2633)

* Event type routing and deserialization issues

In Kafka Streams binder, deserialization exception handler
does not take effect when event type routing is enabled.
Fixing this issue by allowing the applications to use the
configured or inferred Serde rather than the byte[] Serde
used by the event type router initially.

Resolves https://github.com/spring-cloud/spring-cloud-stream/issues/2613

* Addressing PR review
This commit is contained in:
Soby Chacko
2023-01-24 21:49:45 -05:00
committed by GitHub
parent 64aef347e4
commit 0612ea85f7
4 changed files with 207 additions and 11 deletions

View File

@@ -1552,6 +1552,15 @@ For instance, if we want to change the header key on this binding to `my_event`
`spring.cloud.stream.kafka.streams.bindings.process-in-0.consumer.eventTypeHeaderKey=my_event`.
When using the event routing feature in Kafkfa Streams binder, it uses the byte array `Serde` to deserialze all incoming records.
If the record headers match the event type, then only it uses the actual `Serde` to do a proper deserialization using either the configured or the inferred `Serde`.
This introduces issues if you set a deserialization exception handler on the binding as the expected deserialization only happens down the stack causing unexpected errors.
In order to address this issue, you can set the following property on the binding to force the binder to use the configured or inferred `Serde` instead of byte array `Serde`.
`spring.cloud.stream.kafka.streams.bindings.<process-in-0>.consumer.useConfiguredSerdeWhenRoutingEvents`
This way, the application can detect deserialization issues right away when using the event routing feature and can take appropriate handling decisions.
=== Binding visualization and control in Kafka Streams binder
Starting with version 3.1.2, Kafka Streams binder supports binding visualization and control.