I have a Kafka stream processing application written using Spring Boot, using spring-cloud-function
and spring-cloud-stream-binder-kafka-streams
. The method which processes a couple of streams is annotated with @Bean
, so that it should be picked up by spring-cloud-function
(rather than using @StreamListener
). When this method returns a BiFunction
it works. But when I try it as a plain Kotlin lambda it's not picked up by Spring Boot: the app starts then immediately ends as it finds no functions to run.
From what I can see in the documentation, this should work.
Here's the declaration that does work:
@Bean
fun process():
BiFunction<KStream<String, Foo>, GlobalKTable<String, Bar>, KStream<String, Baz>> =
BiFunction { foo, bar ->
...
And here's the declaration that does not work:
@Bean
fun process():
(foo: KStream<String, Foo>, bar: GlobalKTable<String, Bar>) -> KStream<String, Baz> =
{ foo, bar ->
...
(The content of the method is the same in both cases.)
As per the documentation, I have added the spring-cloud-function-kotlin
module to the classpath by adding this to build.gradle.kts
:
implementation("org.springframework.cloud:spring-cloud-function-kotlin")
The version of Spring Cloud Stream is Hoxton.RC1
.
Is there anything else I need to do to get the function picked up? Or do I need to use BiFunction
in this case?