Kiran Kumar
Kiran Kumar

Reputation: 788

recipient-list-router is sending wrong payload in the channel

This is my spring-integration inbound and out bound which gets a list from a end point.

<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>

This is my recipient-list-router which send backs the list to requestor and also saves the list in another end point.

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

This the another outbound end point where save happens

<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>

The issue I am facing is recipient-list-router instead of send the list which we got in the first call to the requestor, it is sending the response from second call that is the save successfull response.

Upvotes: 1

Views: 220

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121442

Consider to use one-way http:outbound-channel-adapter instead of request-reply gateway as you do now for the second call - for that SaveGateway bean definition:

<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>

If you can't use that one consider to add reply-channel="nullChannel" to the HTTP gateway definition.

Upvotes: 2

Related Questions