8

我有一个OSGi捆绑部署在Apache Karaf. 我有一个简单的骆驼路线:

    <camelContext trace="true" xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="jetty:http://0.0.0.0:8282/services?handlers=securityHandler&amp;matchOnUriPrefix=true"/>
            <setHeader headerName="CamelHttpQuery">
                <constant>wt=xml&amp;rows=1000000&amp;fl=nid,title&amp;fq=sm_vid_Third_parties_with_which_this_organisation_s_content_can_be_shared:%22Indeed%22</constant>
            </setHeader>
            <to uri="http://172.28.128.158:8983/solr/targetjobs.co.uk.gtimedia.test/select/?"/>

<!--        <split>
                <xpath>//int[@name='nid']</xpath>
            </split>-->
            <convertBodyTo type="java.lang.String" />
        </route>
    </camelContext>

我无法让它工作。当我调用http://localhost:8282/services它时,它应该路由到uri下面指定的setHeader. 相反,我得到了这个例外:

java.lang.IllegalArgumentException:无效的 uri:/服务。如果您要转发/桥接 http 端点,请在端点上启用 bridgeEndpoint 选项:端点 [ http://172.28.128.158:8983/solr/targetjobs.co.uk.gtimedia.test/select/]

它说我需要启用网桥端点,但这不是端点,它是我试图指向我的路由的绝对 URL。

我已尝试按此处Spring所示进行设置,但这也不起作用。我还尝试更改此设置:

<to uri="http://172.28.128.158:8983/solr/targetjobs.co.uk.gtimedia.test/select/?"/>

对此:

<to uri="jetty//http://172.28.128.158:8983/solr/targetjobs.co.uk.gtimedia.test/select/?"/>

也没有成功。也许有人知道如何从jetty uri绝对路由url

4

2 回答 2

7

你试过bridgeEndpoint吗?如下所述:

http://camel.apache.org/how-to-use-camel-as-a-http-proxy-between-a-client-and-server.html

您的目标网址将如下所示:

<to uri="jetty//http://172.28.128.158:8983/solr/targetjobs.co.uk.gtimedia.test/select?bridgeEndpoint=true&amp;throwExceptionOnFailure=false"/>
于 2012-08-22T09:33:08.487 回答
0

为我工作:

@Override
public void configure() throws Exception {

  restConfiguration()
    .host("localhost")
    .component("jetty")
    .port("8085");

  rest("/api")

    //NEW ROUTE
    .get("/getResidences")
    .produces("application/json")

    //OLD ROUTE
    .to("http://localhost:3000/api/residences?bridgeEndpoint=true&throwExceptionOnFailure=false");

}

注意休息配置中的 .componet("jetty")

于 2019-04-12T20:11:33.017 回答