http inbound gateway path url mapping

自古美人都是妖i 提交于 2019-12-13 02:49:45

问题


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:


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


来源:https://stackoverflow.com/questions/26540814/http-inbound-gateway-path-url-mapping

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!