Spring integration 如何在与SI流中的多个端点交互期间管理有效负载
我试图了解在与多个端点通信的SI流中处理有效负载的可用选项 我使用int-ws:inbound-gateway定义了一个web服务入口点。它接收具有以下有效负载的SOAP消息: SOAP请求Spring integration 如何在与SI流中的多个端点交互期间管理有效负载,spring-integration,Spring Integration,我试图了解在与多个端点通信的SI流中处理有效负载的可用选项 我使用int-ws:inbound-gateway定义了一个web服务入口点。它接收具有以下有效负载的SOAP消息: SOAP请求 <soapenv:Envelope> <soapenv:Header/> <soapenv:Body> <emp:Employee> <emp:EmpId>sf</emp:EmpId> <emp
<soapenv:Envelope>
<soapenv:Header/>
<soapenv:Body>
<emp:Employee>
<emp:EmpId>sf</emp:EmpId>
<emp:EmpName></emp:EmpName>
</emp:Employee>
</soapenv:Body>
</soapenv:Envelope>
科幻小说
然后,SI流提取EmpId并将其作为字符串有效负载传递给JMS队列。JMS端点以字符串类型的形式回复员工姓名。然后,SI流将员工姓名映射到响应消息中的元素EmpName
SOAP响应
<soapenv:Envelope>
<soapenv:Header/>
<soapenv:Body>
<emp:Employee>
<emp:EmpId>sf</emp:EmpId>
<emp:EmpName>Spring Framework</emp:EmpName>
</emp:Employee>
</soapenv:Body>
</soapenv:Envelope>
科幻小说
弹簧框架
为了实现这个用例,我使用了索赔检查模式。还使用标题存储来自JMS端点的回复
考虑到SI流可以与JMS端点之外的其他端点(每个端点都有自己的数据交换格式)进行通信这一事实,如果您可以建议任何其他方法,这将非常有帮助。另外,我希望避免使用头来存储JMS应答负载
配置文件
对于您的案例,我只看到模式,它的实现如下
在春天的时候,整合
因此,您需要将XML请求解组到POJO,例如使用JAXB。配置多个
,并将下游回复映射到POJO的适当属性
最后,在所有阶段之后,您应该将最终的POJO封送回XML,并通过SOAP作为响应发送
样本是。谢谢@Artem。您的解决方案非常适合我的用例。
<int-ws:inbound-gateway id="ws-inbound-emp-gateway" request-channel="ws-requests"
marshaller="jaxbMarshaller" unmarshaller="jaxbMarshaller"
header-mapper="customMapper" />
<int:chain input-channel="ws-requests" output-channel="responsePipe">
<int:claim-check-in message-store="simpleMessageStore"/>
<int:header-enricher>
<int:header name="msgId" expression="payload"/>
</int:header-enricher>
<int:transformer expression="headers['msgId']"/>
<int:claim-check-out message-store="simpleMessageStore" remove-message="false"/>
<int:transformer expression="payload.getEmpId()"/>
<int-jms:outbound-gateway request-destination="requestQueue" reply-destination="responseQueue"
requires-reply="true"/>
</int:chain>
<int:chain input-channel="responsePipe" >
<int:header-enricher>
<int:header name="empNameResponse" expression="payload"/>
</int:header-enricher>
<int:transformer expression="headers['msgId']"/>
<int:claim-check-out message-store="simpleMessageStore" remove-message="true"/>
<int:enricher>
<int:property name="empName" expression="headers['empNameResponse']"/>
</int:enricher>
</int:chain>