spring集成聚合来自出站网关的响应

spring集成聚合来自出站网关的响应,spring,spring-integration,aggregator,Spring,Spring Integration,Aggregator,我希望合并来自两个webservice调用的响应。聚合将基于响应中的键值进行 ws1、ws2(来自ws1和ws2的响应被传递到聚合器)--->聚合器-->响应。 我返回以下代码。聚合器未被调用,不确定我缺少了什么 <int-ws:outbound-gateway id="marshallingGateway1" request-channel="RequestChannel1" reply-channel="replyChannel"

我希望合并来自两个webservice调用的响应。聚合将基于响应中的键值进行

ws1、ws2(来自ws1和ws2的响应被传递到聚合器)--->聚合器-->响应。 我返回以下代码。聚合器未被调用,不确定我缺少了什么

 <int-ws:outbound-gateway id="marshallingGateway1" request-channel="RequestChannel1" reply-channel="replyChannel"
                             uri="https://abc:8080/" message-sender="messageSender"
                             marshaller="marshaller" unmarshaller="marshaller">
        <int-ws:request-handler-advice-chain>
            <ref bean="retryAdvice"/>
        </int-ws:request-handler-advice-chain>
    </int-ws:outbound-gateway>
    <int-ws:outbound-gateway id="marshallingGateway2" request-channel="RequestChannel2" reply-channel="replyChannel"
                             uri="https://abc:8080/" message-sender="messageSender"
                             marshaller="marshaller" unmarshaller="marshaller">
        <int-ws:request-handler-advice-chain>
            <ref bean="retryAdvice"/>
        </int-ws:request-handler-advice-chain>
    </int-ws:outbound-gateway>


    <int:aggregator id="responseAggregator" input-channel="replyChannel" ref="responseAggregator" message-store="messageStore" send-partial-result-on-expiry="true"/>

    <bean id="messageStore" class="org.springframework.integration.store.SimpleMessageStore"/>
    <bean id="responseAggregator" class="abc.cbd.ResponseAggregator"/>

您似乎没有在这两个结果之间建立任何关联

默认情况下,默认关联策略使用标题
correlationId

您还需要一个
发布策略
。它可以简单到
发布策略expression=“size==2”

默认发布策略使用
sequenceSize
sequenceNumber
标题


如果您使用发布-订阅频道向两个网关发送相同的消息,请将
apply sequence
属性设置为
true
,这样您就不需要自定义发布或关联策略。

感谢您的快速响应。我添加了发布策略,它仍然是一样的。发送到网关的消息是不同的。gatways的请求参数是不同的。您需要一些东西将两个结果关联到一个组中以便发布。假设您将这两条消息的某些标题(
foo
)设置为
bar
,那么它们将被分组,并将参考发布策略(例如
correlation strategy expression=“headers['foo']””
。正如我所说,标准关联策略使用
correlationId
头-您需要为每条消息将其设置为相同的值(可以通过发送原始消息的任何消息在网关之前执行)。或者,如果您可以在响应中关联某些内容,这也会起作用。明白了。您可以给我指一个示例,其中发布策略与响应中的某些内容相关。我的要求是,来自ws1的响应是关键abc,值1-123,来自ws2的响应是关键abc,值456。我需要组合响应并创建一个对象/JSON表示{key:“abc”,value1:“123”,“value2”456}。WS1和ws2被多次调用。如果响应是XML,则可以使用
#xpath
SpEL函数关联键
相关策略表达式=“#xpath(…)“
-请参阅。还有
#jsonPath
。使用未编组的XML,您可以在有效负载上使用一个简单的表达式
…expression=“payload.key”
将在有效负载对象上调用
getKey()
。如果它被解组为
映射,请使用
“payload['key']”