-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Support custom KafkaStreams implementations #3516
Conversation
spring-kafka/src/main/java/org/springframework/kafka/config/StreamsBuilderFactoryBean.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Add a section in the reference docs.
- Add a section in the
whats-new
docs.
spring-kafka/src/main/java/org/springframework/kafka/config/KafkaStreamsCustomizer.java
Show resolved
Hide resolved
spring-kafka/src/main/java/org/springframework/kafka/config/KafkaStreamsCustomizer.java
Show resolved
Hide resolved
spring-kafka/src/test/java/org/springframework/kafka/config/KafkaStreamsCustomizerTests.java
Show resolved
Hide resolved
@@ -82,7 +82,7 @@ A new `KafkaStreams` is created on each `start()`. | |||
You might also consider using different `StreamsBuilderFactoryBean` instances, if you would like to control the lifecycles for `KStream` instances separately. | |||
|
|||
You also can specify `KafkaStreams.StateListener`, `Thread.UncaughtExceptionHandler`, and `StateRestoreListener` options on the `StreamsBuilderFactoryBean`, which are delegated to the internal `KafkaStreams` instance. | |||
Also, apart from setting those options indirectly on `StreamsBuilderFactoryBean`, starting with _version 2.1.5_, you can use a `KafkaStreamsCustomizer` callback interface to configure an inner `KafkaStreams` instance. | |||
Also, apart from setting those options indirectly on `StreamsBuilderFactoryBean`, starting with _version 2.1.5_, you can use a `KafkaStreamsCustomizer` callback interface to configure an inner `KafkaStreams` instance and (from _version 3.3.0_) instantiate a custom implementation of `KafkaStreams`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe split them into two lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No splitting of sentences to multi lines, please: https://asciidoctor.org/docs/asciidoc-recommended-practices/#one-sentence-per-line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I would go different sentences at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I kept sentences to one line where it made sense but separated some paragraphs so that it it is easier to read (I had actually struggled to read the initial flow as one paragraph has many different concepts mixed together). Here's the new look:
Since I'm not 100% sure what the standard is here, feel free to suggest edits or push to this branch directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what I meant was splitting them into two separate sentences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still missing some author tags.
1. (from _version 2.1.5_) an inner `KafkaStreams` instance using `customize(KafkaStreams)` | ||
2. (from _version 3.3.0_) instantiate a custom implementation of `KafkaStreams` using `initKafkaStreams(Topology, Properties, KafkaClientSupplier)` | ||
|
||
Note that `KafkaStreamsCustomizer` overrides the options provided by `StreamsBuilderFactoryBean`. If you need to perform some `KafkaStreams` operations directly, you can access that internal `KafkaStreams` instance by using `StreamsBuilderFactoryBean.getKafkaStreams()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second sentence needs to be on a new line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it! Thanks for bearing with me while I figure out what's standard with the docs here 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't comment on any of the Spring-related parts, but as a Kafka committer this change makes sense to me
@agavra The PR build failed due to some checkstyle issues. Can you run a local build and fix them? |
Hmm, test failures seem to be unrelated? Have you seen these before @sobychacko?
|
FYI @sobychacko looks like it's related to spring-aop, pinning spring-aop to
|
We will look into it today. |
Thanks for the PR and for bringing the AOP proxy issue to our attention. We downgraded the framework dependency to the recent |
Fixes #3515. This PR introduces the ability to customize the instantiation of
KafkaStreams
using theKafkaStreamsCustomizer
interface.