Read properties from database and use it instead of mule-app.properties
<p>I have been able to read the properties from a table in the database as it was described here <a href="https://stackoverflow.com/questions/19457356/reading-mule-config-from-database">Reading mule config from database</a></p>

<p>Now, I am not able to apply these properties to the flow configs and also access them as out bound properties in the Java Processor classes through the MuleEventContext's message.</p>

<p>Update: below is my flow XML code</p>

<pre><code>&lt;flow name="push-data"&gt;
    &lt;poll doc:name="Push Poll"&gt;
        &lt;fixed-frequency-scheduler frequency="${push.data.poll.frequency}"  timeUnit="MINUTES" /&gt;
    &lt;set-property propertyName="tempFilePath" value="${temp.csv.file.path}" doc:name="Property"/&gt;

    &lt;component class="com.reports.processors.PushDataProcessor" doc:name="PushDataProcessor"/&gt;
    &lt;logger message="worked!!!" level="INFO" doc:name="Logger"/&gt;
    &lt;exception-strategy ref="push-report-data_Catch_Exception_Strategy" doc:name="Reference Exception Strategy"/&gt;
&lt;/flow&gt;
</code></pre>

<p>I am trying to set the properties "push.data.poll.frequency" and "temp.csv.file.path". Earlier, these properties existed in the "mule-app.properties" file.</p>

<p>So, My question is, How do I set the properties loaded from the database to the flow. Please keep in mind that I have already loaded the properties from the database as described in the link above. I just want to be able to set these properties to the flow rather than taking them from the mule-app.properties.</p>

<p><strong>EDIT: To add some more information,</strong> 
I am using a class with @Configuration annotation. The class as described in the link above, loads the properties from the database. Below is the source code.</p>

<pre><code>@Configuration(name="databasePropertiesProvider")
@Component
public class DatabasePropertiesProvider {

@Autowired(required=true)
private MyService myService;

@Bean
public Properties getProperties() throws Exception {
    Properties properties = new Properties();
    // get properties from the database
    Map&lt;String,String&gt; propertiesMap =    myService.getMuleAppPropertiesFromDB();
    if(null != propertiesMap &amp;&amp; !CollectionUtils.isEmpty(propertiesMap))
        properties.putAll(propertiesMap);
    return properties;
}

@Bean
 public static PropertySourcesPlaceholderConfigurer placeHolderConfigurer() {
    return new PropertySourcesPlaceholderConfigurer();
 }}
</code></pre>

<p>But this class runs after the app is initialized. Previously, I had configured the PropertySourcesPlaceholderConfigurer in the xml config with the factory-bean as the DatabasePropertiesProvider class. But since DatabasePropertiesProvider has a dependency on MyService class, and the dependency was not getting resolved due to MyService bean not initializing in the container before the property config, I had to make some changes to DatabasePropertiesProvider(the version above) so that this runs after the app initialization. </p>

<p>But now, the problem is that I am unable to access those properties that are loaded from the database. </p>

<p><strong>UPDATE 2:</strong> I found a solution. Apparently I was trying to autowire the @Service MyService in the databasePropertiesProvider class. The autowiring was failing with null due to which I made some more modifications to the databasePropertiesProvider class so that It runs after the app is initialized.</p>

<p>Now when I look at it, I realized that I dont need to connect to the database through all the service and repository layers. I moved the query execution code from the repository class to the databasePropertiesProvider class and now the properties are loaded during initialization time and the flows can get the properties without making any changes.</p>

<p>Thanks for all your help guys. Made me do a lot of thinking.</p>

<p>Regards,
Zulfiqar</p>