骆驼HTTP端点动态形成url



伙计们,我正试图使用

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

,这个url会在每次请求路由时改变。

我已经试过了。将参数作为报头传递,并尝试使用报头("test")和使用${in.header在路由中访问。Test} both似乎不起作用。

任何建议都会很有帮助的。

从camel 2.16开始,您可以这样做-

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

参考:http://camel.apache.org/message-endpoint.html

查看Camel中动态to端点的常见问题解答:https://camel.apache.org/manual/latest/faq/how-to-use-a-dynamic-uri-in-to.html

可以使用camel属性占位符

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.

您可以对<to uri="" also

使用相同的方法

最新更新