Skip to content

Optionally configure serialisers #2274

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

Closed
gurpiarbassi opened this issue May 14, 2022 · 2 comments
Closed

Optionally configure serialisers #2274

gurpiarbassi opened this issue May 14, 2022 · 2 comments

Comments

@gurpiarbassi
Copy link
Contributor

Expected Behavior

Sometimes you have already configured your serialiser by calling configure() on it and do not want the spring framework to reconfigure it.

Current Behavior

In version 2.8.4, if you have already configured your serialiser, the DefaultKafkaProducerFactory attempts to reconfigure it from scratch and all your settings are lost.

Context

It would be nice to have a flag/switch to indicate whether you want spring to configure your serialiser for you or not as discussed in this Stackoverflow thread: https://stackoverflow.com/questions/72228636/spring-kafka-serialiser-config/72231032?noredirect=1

@garyrussell
Copy link
Contributor

I agree that we should add a flag to disable the configure() call.

In the meantime, as a work around, use

factory.setValueSerializerSupplier(() -> myConfiguredSerializer);

It's probably a bug, but setting the serializer this way skips the configure() call.

@artembilan
Copy link
Member

@garyrussell ,

Yes, it really looks like a bug. According to that your PR: https://github.com/spring-projects/spring-kafka/pull/1907/files#diff-ee2dfb7123c02f066d237b437f06f37c6ab26279ed47f3edd8b7ca0d0a4c96cdR285, the DefaultKafkaConsumerFactory does call a configure() even for the supplier setters.
The DefaultKafkaProducerFactory does not as we see.

But your idea to leverage a setter API for this kind of requested option indeed makes sense for me.
Although it is not obvious and requires JavaDocs reading. 😄

garyrussell added a commit to garyrussell/spring-kafka that referenced this issue May 16, 2022
Resolves spring-projects#2274

Provide an option to suppress configuring programmatically provided
`Serializer`s and `Deserializer`s.

Also fix the DKPF, which did not configure serializers provided by the
supplier setter.
artembilan pushed a commit that referenced this issue May 17, 2022
Resolves #2274

Provide an option to suppress configuring programmatically provided
`Serializer`s and `Deserializer`s.

Also fix the DKPF, which did not configure serializers provided by the
supplier setter.
artembilan pushed a commit that referenced this issue May 17, 2022
Resolves #2274

Provide an option to suppress configuring programmatically provided
`Serializer`s and `Deserializer`s.

Also fix the DKPF, which did not configure serializers provided by the
supplier setter.
@garyrussell garyrussell modified the milestones: 3.0 Backlog, 3.0.0-M4 May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants