Kafka Streams function detection improvements (#1033)
* Kafka Streams function detection improvements Allow Kafka Streams functions defined as Component beans to be candidates for establishing bindings. Currently, Kafka Streams functions need to be written as functional beans using @Bean. Adding this improvement so that if applications prefer to write the business logic using @Component, then it is possible to do so. Adding test cases to verify the behavior. Resolves https://github.com/spring-cloud/spring-cloud-stream-binder-kafka/issues/1030 * Kafka Streams functions and bean name overriding Whn Kafka Streams function bean names are overridden, there is an issue with scanning it properly for binding. Addressing this issue. * Adding docs for Component based model * Addressing PR review comments
This commit is contained in:
@@ -77,6 +77,22 @@ NOTE: If the destination property is not set on the binding, a topic is created
|
||||
|
||||
Once built as a uber-jar (e.g., `kstream-consumer-app.jar`), you can run the above example like the following.
|
||||
|
||||
If the applications choose to define the functional beans using Spring's `Component` annotation, the binder also suppports that model.
|
||||
The above functional bean could be rewritten as below.
|
||||
|
||||
```
|
||||
@Component(name = "process")
|
||||
public class SimpleConsumer implements java.util.function.Consumer<KStream<Object, String>> {
|
||||
|
||||
@Override
|
||||
public void accept(KStream<Object, String> input) {
|
||||
input.foreach((key, value) -> {
|
||||
System.out.println("Key: " + key + " Value: " + value);
|
||||
});
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
[source]
|
||||
----
|
||||
java -jar kstream-consumer-app.jar --spring.cloud.stream.bindings.process-in-0.destination=my-topic
|
||||
|
||||
Reference in New Issue
Block a user