【问题标题】:Spring Integration Asynchronous Http Outbound callSpring 集成异步 Http 出站调用
【发布时间】:2021-07-13 15:31:00
【问题描述】:

我有一个要求,我必须在循环中使用不同的有效负载值对 http 端点进行 Http 出站调用,调用函数不必等待从出站调用收到的响应,所以基本上出站调用将在循环中异步发生。

有没有办法我们可以使用 Http.outboundGateway 来实现这一点

【问题讨论】:

    标签: spring-integration spring-integration-http


    【解决方案1】:

    您只需要将ExecutorChannel 作为该 HTTP 出站网关端点的输入。比如:

    .channel(MessageChannels.executor(someTaskExecutor))
    .handle(Http.outboundGateway(...))
    

    如果您从某个循环中执行此操作,那么您还应该有一个 id 供该通道注入并用于从您的代码发送。如果您不喜欢在代码中处理MessageChannel API,也可以考虑在该通道顶部使用@MessagingGateway 外观。

    在文档中查看更多信息:

    https://docs.spring.io/spring-integration/docs/current/reference/html/messaging-endpoints.html#gateway

    https://docs.spring.io/spring-integration/docs/current/reference/html/core.html#executor-channel

    【讨论】:

      猜你喜欢
      • 2014-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多