0

任何人都可以帮助我使用 Apache FUSE ESB 配置两个具有相同基本 URI 的 JAX-RS 服务吗?我正在使用带有 karaf 容器、Apache Camel 和 CXF (JAX-RS) 的 JBoss FUSE 6.0 版本。配置是使用蓝图完成的。当我只配置一个 JAX-RS 服务时,一切正常。

我正在尝试使用基本 URI 提供两个 JAX-RS Bean http://localhost:9001/rs。第一个 bean ashttp://localhost:9001/rs/rest1和第二个bean http://locahost:9001/rs/rest2

我已经用码头端点定义了两个骆驼上下文。我想我需要两个只使用一个配置的实例,但无法弄清楚如何做到这一点。

这是我的骆驼上下文:

<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 都作为服务引用注入,当我评论其中一条路由时,一切正常。

任何建议如何在骆驼中配置它?

干杯,奥利弗

4

2 回答 2

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"/>
于 2013-07-19T11:16:48.710 回答
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 Beans 现在带有@Path("/"). 现在所有 REST Bean 都有正确的路径。

我需要测试的下一件事是如何将我的两个端点与我的 Web 应用程序包放在同一个 URL 上。

谢谢 !

于 2013-07-25T16:15:51.297 回答