http inbound gateway path url mapping

2019-09-06 20:59发布

i have two int-http:inbound-gateway with path as mentioned below.when i call

http://localhost:8080/XYZ/ABCService/query  -- i expected to call http:inbound-gateway with id ="XYZ"

http://localhost:8080/ABCService/query  - i expected to call http:inbound-gateway with id ="default"

but what happing in its not consistence when i give request to http://localhost:8080/XYZ/ABCService/query it is calling "default" gateway.i understand it because of the path /*Serivce.But i like to know can i give some order or priority or some kind of url mapping to say always check "XYZ" first then check "default"

I am using DispatcherServlet.

<int-http:inbound-gateway id="default"
        path="/*Service/query"
        request-channel="RequestChannel" reply-channel="ResponseChannel"
        supported-methods="POST" reply-timeout="5000" request-payload-type="java.lang.String"
        error-channel="ErrorChannel" mapped-request-headers="xyz-*, HTTP_REQUEST_HEADERS">
    </int-http:inbound-gateway>


    <int-http:inbound-gateway id="XYZ"
        path="/XYZ/*Service/query"
        request-channel="RequestChannel" reply-channel="XYZResponseChannel"
        supported-methods="POST" reply-timeout="5000" request-payload-type="java.lang.String"
        error-channel="ErrorChannel" mapped-request-headers="xyz-*, HTTP_REQUEST_HEADERS">
         <int-http:header name="reply-type" expression="'ABC'" />
    </int-http:inbound-gateway>

   <int:channel id="ResponseChannel">

    </int:channel>


    <int:header-value-router input-channel="ResponseChannel"
        header-name="reply-type">

        <int:mapping value="ABC" channel="XYZResponseChannel" />
    </int:header-value-router>

1条回答
干净又极端
2楼-- · 2019-09-06 21:08

Can elaborate that you really sure that it doesn't work properly?

What I see that both your endpoints have the same config. The dfference is only in the path, but all other attrs are the same.

That means that all your messages independently of path will be send to the RequestChannel.

I've just tested and eveything works well:

<int-http:inbound-gateway path="/*path1" request-channel="path"/>

<int-http:inbound-gateway path="/foo/*path1" request-channel="fooPath"/>
查看更多
登录 后发表回答