recipient-list-router在通道中发送错误的有效负载

时间:2018-03-19 16:53:19

标签: spring-integration

这是我的spring-integration入站和出站,从终点获取列表。

<http:inbound-gateway id="webListGateway"
        request-channel="fromWeb_List" 
        reply-channel="toWeb_List" 
        path="/api/profile/V1/get"
        supported-methods="GET">
       <http:header name="container" expression="#pathVariables.container"/>
       <http:header name="groupName" expression="#pathVariables.groupName"/>
       <http:header name="userId" expression="#pathVariables.userId"/>
      </http:inbound-gateway>

        <int:header-enricher input-channel="fromWeb_List" output-channel="toCloud_List">
            <int:header name="apikey" value=“1234”/>
        </int:header-enricher>

        <http:outbound-gateway id="profileListGateway"
            request-channel="toCloud_List"
            reply-channel="sync_preferences"
            url=“localhost:8081/containers/{container}/groups/{groupName}/values/hierarchy/{userId}"
            http-method="GET"
            expected-response-type="java.lang.String"
            charset="UTF-8"
            extract-request-payload="false"
            header-mapper="headerMapper"
            encode-uri="true" >
            <http:uri-variable name="container" expression="headers.container"/>
            <http:uri-variable name="groupName" expression="headers.groupName"/>
            <http:uri-variable name="userId" expression="headers.userId"/>
        </http:outbound-gateway>

这是我的收件人列表路由器,它将列表发送回请求者,并将列表保存在另一个端点。

<int:recipient-list-router id="syncRouter" input-channel="sync_preferences">
     <int:recipient channel="toWeb_List"/>
    <int:recipient channel="toCloud_Save"/>
</int:recipient-list-router>

这是保存发生的另一个出站终点

<http:outbound-gateway id="SaveGateway"
        request-channel="toCloud_Save" 
            url=“localhost:8082/containers/{container}/groups/{groupName}/values/multiple/users"
        http-method="PUT"
        expected-response-type="java.lang.String"
        charset="UTF-8"
        extract-request-payload="true"
        header-mapper="headerMapper"
        encode-uri="true" >
        <http:uri-variable name="container" expression="headers.container"/>
        <http:uri-variable name="groupName" expression="headers.groupName"/>
    </http:outbound-gateway>

我面临的问题是收件人列表路由器,而不是发送我们在第一次调用请求者时得到的列表,它是从第二次调用发送响应,即保存成功响应。

1 个答案:

答案 0 :(得分:2)

考虑使用单向 http:outbound-channel-adapter代替请求 - 回复网关,就像现在第二次调用一样 - 为SaveGateway bean定义:

<http:outbound-channel-adapter id="SaveGateway"
    channel="toCloud_Save" 
        url=“localhost:8082/containers/{container}/groups/{groupName}/values/multiple/users"
    http-method="PUT"
    charset="UTF-8"
    extract-payload="true"
    header-mapper="headerMapper"
    encode-uri="true" >
    <http:uri-variable name="container" expression="headers.container"/>
    <http:uri-variable name="groupName" expression="headers.groupName"/>
</http:outbound-channel-adapter>

如果您不能使用那个,请考虑将reply-channel="nullChannel"添加到HTTP网关定义。