Camel custom PropertiesComponent

南笙酒味 提交于 2019-12-13 02:49:43

问题


I'm trying to configure a custom PropertiesComponent for my CamelContexts via Spring. According to this page, I simply need to add a bean definition of type org.apache.camel.component.properties.PropertiesComponent. However, my CamelContext isn't picking it and I can't seem to find a way to reference the bean from within the CamelContext. I just keep getting the following error:

PropertiesComponent with name properties must be defined in CamelContext to support property placeholders.

How can add a PropertiesComponent to the context via Spring? (I do not want to use the propertyPlaceholder tag.)

What I have so far. (I'll subclass PropertiesComponent as soon as I can get this working.)

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

<camelContext xmlns="http://camel.apache.org/schema/spring" id="eventService">
    <routeBuilder ref="httpInbound" />
</camelContext>

回答1:


When you define the properties object inside the spring application context, camel will look up the PropertiesComponent from the Spring application context by using that name.




回答2:


Perhaps you are experiencing this camel regression - if so, you can upgrade to 2.11.1 in which it is fixed.




回答3:


Did you try defining property placeholder inside camel context?

<camelContext xmlns="http://camel.apache.org/schema/spring" id="eventService">
    <propertyPlaceholder id="properties" location="classpath:props.properties"/>

    <routeBuilder ref="httpInbound" />
</camelContext>


来源:https://stackoverflow.com/questions/17731225/camel-custom-propertiescomponent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!