2017-06-15 71 views
0

我有一個使用駱駝休息組件的應用程序。本來,我使用駱駝版本v2.17.0和每個休息端點返回時返回代碼200呼叫時。Apache Camel - Spring Rest端點引用

有一天,當我更新我的應用程序的駱駝版本到v2.18.0(沒有任何其他更改)時,所有其餘的端點在調用時返回http返回碼404。 v2.18.4和v2.19.0發生同樣的情況。

我懷疑是否有一個通過Spring休息端點路徑引用的變化。有誰知道如何糾正我的設置?我正在使用的解決方法是將硬編碼字符串移回Spring,這不符合我的意圖。

彈簧設置爲REST服務

<endpoint id="httpAppRouteBuildRemainPath" uri="#{commonUtilService.getEpUtil().getHTTPAppJsonBuildRemainPath()}" /> 
<endpoint id="httpSysRouteBuildRemainPath" uri="#{commonUtilService.getEpUtil().getHTTPSysJsonBuildRemainPath()}" /> 
<endpoint id="httpJsonBuildManagementRouteEndPoint" uri="#{commonUtilService.getEpUtil().getHTTPJsonBuildManagementRouteEndpointPath()}" /> 

<rest path="#commonUtilService.getEpUtil().getHTTPJsonManagementRestPath()"> 
     <put uri="ref:httpAppRouteBuildRemainPath" id="appHttpRouteReceiver"> 
       <to uri="ref:httpJsonBuildManagementRouteEndPoint"/> 
     </put> 
     <put uri="ref:httpSysRouteBuildRemainPath" id="sysHttpRouteReceiver"> 
       <to uri="ref:httpJsonBuildManagementRouteEndPoint"/> 
     </put> 
</rest> 

的Java安裝

public String getHTTPJsonManagementRestPath() { 
     return "/worker/json"; 
} 

public String getHTTPAppJsonBuildRemainPath() { 
     return "/app/build"; 
} 

public String getHTTPSysJsonBuildRemainPath() { 
     return "/sys/build"; 
} 

測試結果

在駱駝版本v2.17.0

2017年6月7日上午11點10分十六秒org.restlet.engine.log.LogFilter afterHandle

INFO:2017年6月7日11點10分16秒0:0:0:0:0: 0:0:1 - - 9395 PUT /工人/ JSON /應用程序/生成 - - -

在駱駝版本v2.18.0

2017年6月7日11:11:33 AM org.restlet.routing.Template getRegexPattern

警告:空模式變量是不允許的:空 2017年6月7日上午11時11分33秒org.restlet.routing.Template getRegexPattern

警告:空模式變量是不允許的:空 07年6月,2017年上午11點11分33秒org.restlet.routing.Template getRegexPattern

警告:空模式變量是不允許的:空 2017年6月7日上午11點11分33秒org.restlet.routing.Template getRegexPattern

警告:不允許使用空模式變量:null Jun 07,2017 11:11:33 AM org.restlet.engine.log。LogFilter afterHandle

INFO:2017年6月7日十一點11分33秒0:0:0:0:0:0:0:1 - - 9395 PUT /工人/ JSON /應用程序/生成 - - -


更新

我改變彈簧設置到

<rest path="/worker/json"> 
    <put uri="/app/build" id="appHttpRouteReceiver"> 
     <to uri="ref:httpJsonBuildManagementRouteEndPoint"/> 
    </put> 
    <put uri="ref:httpSysRouteBuildRemainPath" id="sysHttpRouteReceiver"> 
     <to uri="ref:httpJsonBuildManagementRouteEndPoint"/> 
    </put> 
</rest> 

測試結果

在駱駝版本v2.18.0

2017年6月26日上午10時十二分50秒org.restlet.engine.log.LogFilter afterHandle

信息:2017- 06-26 10時12分五十秒0:0:0:0:0:0:0:1 - - 9395 PUT /工人/ JSON/REF:httpSysRouteBuildRemainPath - - -

2017年6月26日上午10:14:54 org.restlet.engine.log.LogFilter afterHandle

信息:2017-06-26 10:14:54 0:0:0:0:0:0: 0:1 - - 9395 PUT /工人/ JSON/應用程序/構建 - Jakarta通用-的HttpClient/3.1 -

2017年6月26日上午10時18分53秒org.restlet。 engine.log.LogFilter afterHandle

INFO:2017-06-26 10:18:53 0:0:0:0:0:0:0:1 - - 9395 PUT/worker/json/sys/build - 的Jakarta Commons-的HttpClient/3.1 -

+0

你有2個把它最終會以相同的路徑,你應該使用不同的路徑或只有1把 –

+0

@ClausIbsen看起來像其餘端點使用'ref:httpSysRouteBuildRemainPath'作爲路徑而不是查找端點引用。有什麼方法可以從Java端設置值嗎? – hk6279

+0

使用屬性佔位符的{{xxx}}:http://camel.apache.org/using-propertyplaceholder.html –

回答