问题
we are developing an application running on mule-enterprise-3.3.2. For the configuration and tweaking purposes we have many parameters placed in .properties files managed by the spring context (Spring 3.1) using this line:
<context:property-placeholder location="classpath:my-config.properties" />
How can we auto reload the properties on changes without doing a server restart?
Any suggestions?
(Note: I'm not sure, if mule can handle changing of parameter at runtime in general.)
回答1:
Properties are resolved in XML configuration files (Mule or Spring) at initialization time, so you can't change them later on.
One approach to do what you want to do is to define the configuration values in a Groovy bean that implements a Java interface and use Spring to load it from the file system. Spring supports hot reloading Groovy beans so the properties would be reloaded at runtime.
Then inject this configuration bean in the objects that need to support runtime configuration changes. If you need values from this bean in a more static manner, use SpEL to inject the values from the XML configuration.
回答2:
we are able to load a Groovy class using Mule Spring Bean (through the Global Elements tab). You have mentioned that the Groovy bean has to be loaded by Spring for hot reloading. Do you have an example on how to do this in Mule?
The following URL defines how to use Spring beans in Mule but it clearly states that it happens during server startup. http://www.mulesoft.org/documentation-3.2/display/32X/Using+Spring+Beans+as+Service+Components
Could you please let me know how to use Spring in Mule for hot reloading of Groovy beans?
Thank you,
Ananth
来源:https://stackoverflow.com/questions/17406748/mule-3-3-auto-reload-properties