Details
-
Task
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
Unknown
Description
As a result of copying from OrderedProperties to Properties, the order of properties is changed
https://github.com/apache/camel/blob/master/core/camel-base/src/main/java/org/apache/camel/component/properties/AbstractLocationPropertiesSource.java
public Properties loadProperties(Predicate<String> filter) {
Properties answer = new Properties();
for (String name : properties.stringPropertyNames())
return answer;
}
So when creating beans from the application.properties file, the order of their creation changes and beans that depend on other beans are created earlier and do not see the desired beans in the registry
https://camel.apache.org/components/latest/others/main.html#_specifying_custom_beans
For example, in this application.properties
#bus config
camel.beans.busConFactory=#class:org.apache.activemq.ActiveMQConnectionFactory
camel.beans.busConFactory.brokerURL=vm://amq-test-bus?broker.persistent=false
camel.beans.busPoolFactory=#class:org.apache.activemq.pool.PooledConnectionFactory
camel.beans.busPoolFactory.connectionFactory=#busConFactory
camel.beans.busPoolFactory.maxConnections=3
camel.beans.busJmsConfig=#class:org.apache.camel.component.activemq.ActiveMQConfiguration
camel.beans.busJmsConfig.connectionFactory=#busPoolFactory
camel.beans.busJmsConfig.concurrentConsumers=2
camel.beans.busJmsConfig.preserveMessageQos=true
camel.beans.busJmsConfig.transacted=true
camel.beans.BUS=#class:org.apache.camel.component.activemq.ActiveMQComponent
camel.beans.BUS.configuration=#busJmsConfig
Bean "camel.beans.BUS" created before "camel.beans.busJmsConfig" and it did not work