Out of curiosity, did anyone of you play around with supplying lambdas as beans?
I’m talking about the following:
Copy code
@Configuration
class MyConfig {
@Bean
fun sendAnEmail(emailPublisher: EmailPubSubPublisher) = sendAnEmailLambdaVersion(emailPublisher)
}
fun sendAnEmailLambdaVersion(emailPublisher: EmailPubSubPublisher): (SomeEmail) -> Mono<String> =
{ email: SomeEmail -> emailPublisher.send(email) }
sure it works, but throwing
@Bean
on the function directly would be ofc more elegant, but I’m currently making no progress in that direction.
Does anyone have any experience with that? Thanks! 🙂
s
Saharath Kleips
12/15/2021, 6:03 PM
We do this a lot for spring cloud streams, we would normally write this as: