2013-07-18 36 views
0

任何人都可以幫助我使用Apache FUSE ESB配置具有相同基本URI的兩個JAX-RS服務嗎?我正在使用JBoss FUSE 6.0版本的karaf容器,Apache Camel和CXF(JAX-RS)。配置使用Blueprint完成。當我只配置一個JAX-RS服務時,一切正常。具有一個Jetty端點的多個JAXRS Bean

我想服務兩個基礎URI爲http://localhost:9001/rs的JAX-RS Bean。第一個bean爲http://localhost:9001/rs/rest1,第二個爲http://locahost:9001/rs/rest2

我用jetty端點定義了兩個駝峯上下文。我想我需要兩個只使用一個配置的實例,但不知道如何做到這一點。

這裏是我的駱駝上下文:

<camel:camelContext id="context1"> 
    <camel:endpoint id="ep1" uri="jetty:http://localhost:9001/rs/?matchOnUriPrefix=true"/> 
    <camel:route autoStartup="true"> 
     <camel:from uri="ep1"/> 
     <camel:to uri="cxfbean:restBean1"/> 
     <camel:log message="Message received after REST Processor. "/> 
     <camel:convertBodyTo type="java.lang.String"/> 
     <camel:to uri="log:loggingCategory?level=INFO"/> 
    </camel:route> 
</camel:camelContext> 

<camel:camelContext id="context2"> 
    <camel:endpoint id="ep2" uri="jetty:http://localhost:9001/rs/?matchOnUriPrefix=true"/> 
    <camel:route autoStartup="true"> 
     <camel:from uri="ep2"/> 
     <camel:to uri="cxfbean:restBean2"/> 
     <camel:log message="Message received after REST Processor. "/> 
     <camel:convertBodyTo type="java.lang.String"/> 
     <camel:to uri="log:loggingCategory?level=INFO"/> 
    </camel:route> 
</camel:camelContext> 

兩個bean注入作爲服務引用,當我發表意見的途徑之一一切正常。

任何建議如何配置這在駱駝?

乾杯, 奧利弗

回答

1

的2個碼頭終點應該是唯一的,例如,你有兩個與/ RS/ 應該有可能是

<camel:endpoint id="ep1" uri="jetty:http://localhost:9001/rs/rest1/?matchOnUriPrefix=true"/> 

<camel:endpoint id="ep2" uri="jetty:http://localhost:9001/rs/rest2/?matchOnUriPrefix=true"/> 
+0

嗨。我認爲解決這個問題的方法是將兩個Endpoint與bean的路徑包含在一起,並將Bean路徑設置爲「/」。這適用於我的設置。 – Odo

0

我固定的問題有兩個端點

<camel:endpoint id="ep1" uri="jetty:http://localhost:9001/rs/rest1/?matchOnUriPrefix=true"/> 
<camel:endpoint id="ep2" uri="jetty:http://localhost:9001/rs/rest2/?matchOnUriPrefix=true"/> 

REST豆現在與@Path("/")。 現在所有REST Bean都有正確的路徑。

我需要測試的下一件事是如何讓我的兩個端點與我的Web應用程序捆綁在一起在同一個URL上。

謝謝!