Camel Route from Jetty to Absolute URL

Paulius Matulionis picture Paulius Matulionis · Aug 21, 2012 · Viewed 9.4k times · Source

I have an OSGi bundle deployed on Apache Karaf. I have a simple camel route:

    <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>

I can not get it working. When I invoke http://localhost:8282/services it should route to the uri specified in below the setHeader. Instead I am getting this 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/]

It says that I need to enable bridge endpoint, but this is not an endpoint, it is an absolute URL to which I am trying to point my route.

I have tried to set up Spring as shown here but this did not work either.I have also tried to change this:

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

to this:

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

No success as well. Maybe someone knows how to route from jetty uri to absolute url?

Answer

udalmik picture udalmik · Aug 22, 2012

Have you tried bridgeEndpoint? As described below:

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

Your target url will look like:

<to uri="jetty//http://172.28.128.158:8983/solr/targetjobs.co.uk.gtimedia.test/select?bridgeEndpoint=true&amp;throwExceptionOnFailure=false"/>