You are viewing an older version of this section. Click here to navigate to the latest version.

Modularizing Your Configuration Files for Team Development

Though it may seem convenient to keep all your Mule configuration in one place, the reality is that a gigantic XML file quickly becomes unmanageable. This is why it is recommended to split monolithic configurations into several files and leverage Mule’s capacity to load multiple configuration files at application start-up time. Moreover, splitting configurations into multiple fragments encourages re-use across teams.

Mule offers two options for loading several configuration files:

*side-by-side: provide a list of independent configuration files to load, *imported: have one configuration file import several others, which in-turn can import other files.

In practice, it is common to use both approaches simultaneously.

Don’t forget that all the configuration files end up loaded in the same context; therefore you should be careful and use unique names for all your configuration elements. Mule will refuse to load an application whose configuration files contain name conflicts.

How can you determine what constitutes good separation lines between configuration fragments? Here are a few rules of thumb:

*Business domains usually form a natural border that can be used to separated configuration elements *Keeping together elements that have similar reasons for change reduces the risk of impacting unrelated aspects of your application *Technical aspects, like administrative components, security or Spring beans configuration, define good lines of demarcation *Extracting a side-by-side transport configuration (connectors and endpoints) facilitates functional testing (discussed in section 3). Note that it is not intended to take care of environment specific transport configuration, which is dealt with properties files (discussed later on) *And, last but not least, re-use across teams and projects (also discussed later on)

Imported configuration files

Mule relies on Spring XML configuration for importing configuration files into each other.

Here is the main configuration file illustrated above, which takes care of importing the three other configuration elements:

<mule xmlns=""      xmlns:xsi=""      xmlns:spring=""  xsi:schemaLocation="">  <spring:beans>    <spring:import resource="domain-A-config.xml" />    <spring:import resource="domain-B-config.xml" />    <spring:import resource="admin-config.xml" />  </spring:beans></mule>