首页 > 解决方案 > 处理具有相同消息的连续 HTTP 调用

问题描述

我想一个接一个地进行两个顺序调用,但对两个调用使用相同的请求消息。但如我的示例代码所示,第一个 post 调用的响应默认成为第二个调用的请求。spring 集成中这种模式最优雅的解决方案是什么

 public IntegrationFlow test() {
   return IntegrationFlows
       .from("testChannel")
       .handle(httpConfigurations.postCall1())
       .handle(httpConfigurations.postCall2())
       .get();
 }

标签: spring-integrationspring-integration-dsl

解决方案


在第一次.handle添加带有表达式的标题丰富器之前,将其复制payload到标题中。

在第二次之前.handle使用 a.transform()将标头复制回有效负载。


推荐阅读