我有简单的@Bean
(Java 8 函数)映射到目标topic
(-out
和-in
)。
@Bean
public Function<String, String> transform() {
return payload -> payload.toUpperCase();
}
@Bean
public Consumer<String> receive() {
return payload -> logger.info("Data received: " + payload);
}
.yml 配置:
spring:
cloud:
stream:
function:
definition: transform;receive
bindings:
transform-out-0:
destination: myTopic
receive-in-0:
destination: myTopic
现在,我想通过调用来调用该transform
函数,REST
以便它的输出到达destination topic
(即transform-out-0
映射到)并由来自该目的地(映射到)myTopic
的 拾取。基本上,每个 REST 调用都应该生成一个新的KAFKA实例并关闭它。consumer
receive-in-0
myTopic
Producer
我怎样才能做到这一点,请使用spring-cloud-stream
?
谢谢
昂舒曼