我在 Apache Karaf
上部署了一个 OSGi
包。我有一条简单的 Camel 路线:
<camelContext trace="true" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="jetty:http://0.0.0.0:8282/services?handlers=securityHandler&matchOnUriPrefix=true"/>
<setHeader headerName="CamelHttpQuery">
<constant>wt=xml&rows=1000000&fl=nid,title&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
时,它应该路由到 setHeader
下方指定的 uri
。相反,我得到了这个异常(exception):
java.lang.IllegalArgumentException: Invalid uri: /services. If you are forwarding/bridging http endpoints, then enable the bridgeEndpoint option on the endpoint: Endpoint[http://172.28.128.158:8983/solr/targetjobs.co.uk.gtimedia.test/select/]
它说我需要启用网桥端点,但这不是端点,它是我试图指向我的路由的绝对 URL。
我已尝试设置 Spring
,如图所示 here但这也不起作用。我也试图改变这一点:
<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
?
最佳答案
您是否尝试过 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&throwExceptionOnFailure=false"/>
关于java - 从 jetty 到绝对 URL 的 Camel 路线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12058479/