Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Sep 22, 2023

Conversation

artembilan
Copy link
Collaborator

Fixes #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

  • Remove kafka_consumer from a message before it reaches an aggregator with its logic to serialize message into the store

This is a workaround until Spring for Apache Kafka is released with the fix: spring-projects/spring-kafka#2822

Fixes spring-cloud#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

* Remove `kafka_consumer` from a message before it reaches an aggregator
with its logic to serialize message into the store

This is a workaround until Spring for Apache Kafka is released
with the fix: spring-projects/spring-kafka#2822
@artembilan artembilan requested a review from onobc September 22, 2023 14:43
@onobc onobc requested a review from sobychacko September 22, 2023 15:11
Copy link
Collaborator

@onobc onobc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - nice and simple. Thanks @artembilan

@onobc onobc merged commit 46dc4d0 into spring-cloud:main Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Header serialization exception in aggregator processor with Redis
3 participants