camel http endpoint forming url dynamically

2020-07-23 06:26发布

Guys I am trying to use

{
from("direct:a").to (someUrl).processor(new Processor(){

   @Override
   public void process(Exchange arg0) throws Exception
   {
      // do something
   }

});


where someUrl is of the type http://xyz.com/{id}?test=<value1>&test1=<value2>
}

and this url will change on every request to the route.

What i have already tried. Passing params as headers and try to access in the route using the header("test") and using ${in.header.test} both doesn't seem to work.

any suggestions will be greatly helpful.

3条回答
冷血范
2楼-- · 2020-07-23 06:53

From camel 2.16 you can do things like this -

from("direct:start")   
   .toD("${header.foo}");

Refer : http://camel.apache.org/message-endpoint.html

查看更多
女痞
3楼-- · 2020-07-23 06:59

You can use camel property place holder

http://camel.apache.org/using-propertyplaceholder.html

<camelContext trace="false" xmlns="http://camel.apache.org/schema/spring">
    <propertyPlaceholder location="config/AuditJMSConfig.properties" id="properties" />
    <route id="crudRoute">
        <from uri="activeMQ:queue:{{speedwing.activemq.auditqueue}}/>
    </route>                                                                                    where speedwing.activemq.auditqueue is the property name defined in the peroperties file.

you can use the same for <to uri="" also

查看更多
姐就是有狂的资本
4楼-- · 2020-07-23 07:00
登录 后发表回答