让我们像这样定义Spring Cloud函数:
@Bean
public Function<Message, Message> logfileEventFunction() {
log.info("logfileEventFunction consumer defined");
return message -> {
log.info("logfileEventFunction called - {}", message);
return message;
};
}
@Bean
public Consumer<Message> logfileEventConsumer() {
log.info("Logfile consumer defined");
return (logfileEvent) -> {
log.info("Logfile consumer called - {}", logfileEvent);
};
}具有如下属性:
spring.cloud.stream.bindings.logfileEventFunction-out-0.group=logfileEventChannelQueue
spring.cloud.stream.bindings.logfileEventFunction-out-0.destination=logfileEventChannel-out-0
spring.cloud.stream.bindings.logfileEventConsumer-in-0.group=logfileEventChannelQueue
spring.cloud.stream.bindings.logfileEventConsumer-in-0.destination=logfileEventChannel-out-0除了定义的logfileEventChannelQueue之外,Spring还会自动创建名为logfileEventFunction-in-0的匿名队列。我还添加了依赖spring-cloud-function-web来将函数公开为端点。
预期行为是函数通过队列将其输出发送给Consumer。
当我将消息放入匿名队列时,一切正常,匿名队列是函数的输入。然后函数将此消息重新发送到绑定到Customer的另一个队列。
问题是绑定到输出队列的函数在通过REST端点调用时不起作用。函数被调用,但消息不会传递到输出队列。应该是这样吗?我想创建REST端点,它盲目地将所有内容输出到队列中。
发布于 2021-10-15 17:56:39
我相信你是来找StreamBridge的。它是专门为你这样的情况设计的。事实上,我相信所提供的示例恰好描述了您的情况。
如果不是这样,请让我知道
https://stackoverflow.com/questions/69584428
复制相似问题