springwolf / springwolf-core

Automated documentation for event-driven applications built with Spring Boot
https://www.springwolf.dev
Apache License 2.0
253 stars 77 forks source link

Springwolf spring-cloud-stream should support BiConsumer and BiFunction #1071

Open LeovR opened 2 days ago

LeovR commented 2 days ago

Describe the feature request With Spring Cloud Stream one is able, in addition to Function and Consumer-Beans to use BiFunction or BiConsumer-Beans. E.g. with a Kafka-Binder, a BiConsumer can be used to also consume the Kafka-Headers. Currently, only Consumer, Function or Supplier can be used.

In addition, the DefaultBeanMethodsScanner should also consider all @Component-Beans and not just bean-methods in @Configuration-classes because those can also be provided via other @Component-annotations.

Motivation We're relying on BiConsumer to consume headers.

Technical details It should be considered, whether the Spring FunctionCatalog could be used to get a hold of the function-bindings, since all the scanned functions are already registered in the catalog.

github-actions[bot] commented 2 days ago

Welcome to Springwolf. Thanks a lot for reporting your first issue. Please check out our contributors guide and feel free to join us on discord.

timonback commented 1 day ago

Hello @LeovR , that is a great addition.

Do you have a code example for the usage with headers? (Can be added to the cloudstream example later) In the docs, I found a section where messages from two different topic are consumed: https://docs.spring.io/spring-cloud-stream/reference/kafka/kafka-streams-binder/programming-model.html#multiple-input-bindings

Feel free (or anyone) to pick this up and contribute

LeovR commented 1 day ago

Hi @timonback,

unfortunately this feature is not documented very well. The link you provided is about the Kafka Streams binding and not the "normal" Kafka binding.

I will pick this up myself then and create a pull request when I'm done.

At least I wanted to make sure whether this is wanted.