Spring Cloud Stream - 使用 spring 云函数(特别是 "Function")作为 rest 端点公开并发布到主题

Spring Cloud Stream - use spring cloud function("Function" specifically) to expose as rest endpoint and publish to a topic

使用 Spring Cloud Stream - 是否可以使用 spring 云函数(特别是“函数”)作为 rest 端点公开并发布到主题 - 如下所示 -

@Bean
  public Function<String,String> postLoginEvent() {
    return valFrmRest -> valFrmRest;
  }

目前,如果我尝试这个,端点没有暴露,我得到 404。作为一种解决方法,我使用 EmitterProcessor 从其余端点获取输入并单独有一个供应商 return这个处理器发布到一个主题。不确定我问的问题在技术上是否可行,但它可能是一个非常常见的用例,并且提供开箱即用的功能会很好。有什么想法吗?预先感谢您分享您的意见。

您可以将其作为 REST 端点,然后使用 StreamBridge API 以编程方式发布它。查看详情here.

这里是 sample 使用 StreamBridge