2013-02-25 21 views
2

,大家好我试图用骆驼HTTP端点形成网址动态

{ 
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会改变每个请求的路径。

我已经试过了。传递params作为头文件并尝试使用头文件(“test”)和$ {in.header.test}在路径中访问这两个文件似乎都不起作用。

任何建议将大有帮助。

回答

4

看到这个常见问题,了解动态到端点的骆驼:http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html

+3

再次阅读常见问题解答!您不能在TO中使用动态值,您应该使用RECIPIENT LIST。 – 2013-02-26 07:20:18

+0

是收件人列表工作像魔术。 – 2013-02-27 05:36:01

+0

好,你能回答这个问题吗? – 2013-02-27 07:11:50

1

可以使用骆驼属性占位

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

+1

这是“半动态” - 当骆驼被初始化时,属性被使用,从这时起_ <到uri_具有恒定的值。但问题是关于每个请求的动态端点。 – 2015-03-20 14:52:37