![](/img/trans.png)
[英]Spring Cloud Stream function with Spring Cloud Contract
[英]Convert Spring Cloud Stream to use reactive cloud function
目前我有類似這樣的 Spring Boot 應用程序。
@Component
@EnableBinding(Source::class)
class EmailMessageProducer(private val source: Source) {
suspend fun send(textMessage: TextMessage) {
source.output().send(
MessageBuilder.withPayload(textMessage).setHeader("service", "test").build()
)
}
}
我想在這里使用響應式模式使用 Spring Cloud Function。
此外,我當前的解決方案是非阻塞的嗎? 我問這個是因為這是我第一次在這種情況下使用 Kotlin 協程。
Java 解決方案也適用於我,因為我只是想了解這里的概念。
您正在尋找的是反應式供應商(例如, Supplier<Flux>
)。
在您的情況下,它看起來像這樣:
@SpringBootApplication
public class SomeApplication {
@Bean
public Supplier<Flux<Message<String>>> messageProducer() {
return () -> Flux.just(MessageBuilder.withPayload(textMessage).setHeader("service", "test").build());
}
}
提供spring.cloud.function.definition=messageProducer
屬性就spring.cloud.function.definition=messageProducer
了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.