spring-cloud / stream-applications

Functions and Spring Cloud Stream Applications for data driven microservices
https://spring.io/projects/spring-cloud-stream-applications
247 stars 106 forks source link

GH-500: Workaround for non-serializable header #503

Closed artembilan closed 11 months ago

artembilan commented 11 months ago

Fixes https://github.com/spring-cloud/stream-applications/issues/500

When listeners are provided for DefaultKafkaConsumerFactory, the target KafkaConsumer instance is proxied. The java.lang.reflect.Proxy is Serializable, but the value it is wrapping is not. When the MessageHeaders is serialized (e.g. into persistent MessageStore), it checks for Serializable type only on top-level object of the header. Therefore, the Proxy is passing condition, but eventually we fail with NotSerializableException, since the proxied object is not like that

This is a workaround until Spring for Apache Kafka is released with the fix: https://github.com/spring-projects/spring-kafka/pull/2822