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

Feature request: enable recreation of kafka producer during runtime with spring-cloud-stream #2827

Open
DigitalMediageek opened this issue Oct 10, 2023 · 2 comments

Comments

@DigitalMediageek
Copy link

Feature:
Recreation of kafka producer during runtime

Description:
It should be possible to allow recreation of kafka producers during runtime (means: spring boot aplication must not be restared). This can be useful, e.g. if connection security properties change, like a new client certificate being provided, etc.

Current mode:
Currently, e.g. SSLContext can be modified by specifying a custom SslEngineFactory. However, this applies only during creation time of a kafka producer and cannot be updated during lifetime.

Future mode:
Producer lifecycle could be modified by using setMaxAge() or reset() of DefaultKafkaProducerFactory. However, when using spring-cloud-stream, one can neither get a hold of DefaultKafkaProducerFactory, nor replace it with a custom implementation, because its explicitly referenced.
Of course, various other possibilities exist to implement.

Versions:
Observed with Spring Boot 3.0.11 and Spring 2022.0.4.

Reference:
See https://stackoverflow.com/questions/77257927/refreshing-kafka-producer-during-runtime-in-spring-application/77259917#77259917

@olegz
Copy link
Contributor

olegz commented Oct 20, 2023

This is possible today since the responsible classes are Lifecycle, so all you need to do is context.stop(), context.start(). What else do you expect?

@DigitalMediageek
Copy link
Author

As far as I know, this does not affect kafka producers.

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

2 participants