GH-621: Add KafkaStreams customizer

Fixes spring-projects/spring-kafka#621

Refactor;
- Revert configurer
- Add setters to `StreamsBuilderFactoryBean`
- Create `CompositeKafkaStreamsCustomizer`

Polish, update docs.

* Polishing code style, Docs and Java Docs
This commit is contained in:
Nurettin Yilmaz
2018-03-27 02:36:29 +03:00
committed by Artem Bilan
parent 202f73cfa4
commit e77e1efbc5
5 changed files with 243 additions and 12 deletions

View File

@@ -70,7 +70,9 @@ If you would like to control lifecycle manually (e.g. stop and start by some con
Since `StreamsBuilderFactoryBean` utilize its internal `KafkaStreams` instance, it is safe to stop and restart it again - a new `KafkaStreams` is created on each `start()`.
Also consider using different `StreamsBuilderFactoryBean` s, if you would like to control lifecycles for `KStream` instances separately.
You can specify `KafkaStreams.StateListener` and `Thread.UncaughtExceptionHandler` options on the `StreamsBuilderFactoryBean` which are delegated to the internal `KafkaStreams` instance.
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_, a `KafkaStreamsCustomizer` callback interface can be used to configure inner `KafkaStreams` instance.
Note that `KafkaStreamsCustomizer` will override the options which are given via `StreamsBuilderFactoryBean`.
That internal `KafkaStreams` instance can be accessed via `StreamsBuilderFactoryBean.getKafkaStreams()` if you need to perform some `KafkaStreams` operations directly.
You can autowire `StreamsBuilderFactoryBean` bean by type, but you should be sure that you use full type in the bean definition, for example: