Camel-如何在以xml编写的路由中使用文件中设置的属性

Heartlex

我在没有spring的情况下在骆驼xml路由中使用属性遇到了一些麻烦。我正在尝试使用“ to uri”标签中的属性,到目前为止,我已经实现了以下结果:

<to uri="properties:{{url}}{{delimiter}}throwExceptionOnFailure=false?locations=endpoint.properties"/>

url是“ http4:// localhost:8080”之类的键,而定界符是“?”的键。我使用此变通办法来能够对http4组件使用throwExceptionOnFailure选项,并避免FailedToCreateRouteException。还有另一种方法可以避免异常吗?我也试图使用simple和receiveerList获得另一种解决方案,但是直到现在我只得到错误。

先感谢您

fg78nc

您需要先确保已加载属性占位符,然后才能使用它。

PropertiesComponent props = camelContext.getComponent("properties", PropertiesComponent.class);
props.setLocation("classpath:yourfile.properties:);

在XML中:

<bean id="props" class="org.apache.camel.component.properties.PropertiesComponent">
  <property name="location" value="classpath:yourfile.properties" />
</bean>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章