【问题标题】:http inbound gateway path url mappinghttp入站网关路径url映射
【发布时间】:2014-10-24 03:02:04
【问题描述】:

我有两个 int-http:inbound-gateway,路径如下所述。当我调用时

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"

但是当我向http://localhost:8080/XYZ/ABCService/query 提出请求时,它的不一致发生了什么 它正在调用“默认”网关。我理解它是因为路径/*服务。但我想知道我可以给出一些顺序或优先级或某种 url 映射说总是先检查“XYZ”然后检查“默认”

我正在使用 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>

【问题讨论】:

    标签: spring-mvc spring-integration


    【解决方案1】:

    能否详细说明您确实确定它不能正常工作?

    我看到您的两个端点具有相同的配置。差异仅在路径中,但所有其他属性都相同。

    这意味着您所有独立于path 的消息都将发送到RequestChannel

    我刚刚测试过,一切正常:

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

    【讨论】:

    • 感谢您的回复。对不起,我的错误是我打算放不同的回复频道,只是错误地放了相同的回复频道。我在原始消息中编辑了正确的回复。所以问题当我请求 localhost:8080/XYZ/ABCService/query 时,我正面临着每隔一次收到回复通道 =“响应通道”的回复,而这期望来自回复通道 =“XYZResponseChannel”
    猜你喜欢
    • 2019-01-05
    • 1970-01-01
    • 2017-02-19
    • 2012-07-14
    • 2015-03-28
    • 2011-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多