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

pes8fvy9  于 5个月前  发布在  Apache
关注(0)|答案(1)|浏览(49)

我在没有spring的camel xml route中使用属性时遇到了一些问题。我试图在'to uri'标签中使用属性,到目前为止我已经实现了这个结果:

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

字符串
url是“http 4://localhost:8080”的关键字,而url是“?”的关键字。我使用了这个解决方案,以便能够为http 4组件使用throwExceptionOnFailure选项,并避免FailedToExceptionRouteException。有没有其他方法可以不获取异常?我也试图使用simple和ExcepentList获得另一种解决方案,但到目前为止,我只得到错误。
提前感谢您

jum4pzuy

jum4pzuy1#

您需要确保在使用属性占位符之前已加载它。

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>

相关问题