About Mule Configuration
This topic relates to the most recent version of Mule Runtime.
Following is an introduction to configuring Mule ESB via the Spring XML file.
Overview of a Mule Configuration
A Mule configuration file is similar to a tree, as shown in the following illustration:
Each of these elements provides access to configuration object within Mule:
-
Custom Message processors - Observe a message, or modify either a message or the message flow. Examples include transformers and filters.
-
Flows- Use message processors to define message flow between a source and a target.
-
Mule Global Configuration - Global settings, such as the default transaction time-out, that apply to the entire Mule configuration
-
Connectors - Non-default configuration of any transports used
-
Endpoints - Define the channel and address or path where messages are sent or received. You can define them globally and use them in multiple flows.
-
Transformers - Convert data from one format to another. You can define them globally and use them in multiple flows.
-
Filters - Filter out the messages that don’t match specific criteria. You can define them globally and use them in multiple flows.
-
Models - One or more models that logically group together your services.
-
Services - One or more services that wrap your components (business logic) and configure routers, endpoints, transformers, and filters specifically for that service
Following is an example of a simple Mule configuration file:
Simple Mule Configuration
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.0/mule.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.0/mule-vm.xsd">
<vm:connector name="vmConnector" queueTimeout="5000"/>
<vm:endpoint name="CustomerRequests" path="customer.requests"/>
<vm:endpoint name="CustomerResponses" path="customer.responses"/>
<custom-transformer name="ThisToThat" class="com.acme.transformer.ThisToThat"/>
<flow name="myBasicFlow">
<inbound-endpoint ref="CustomerRequests"/>
<component class="com.acme.service.BasicService"/>
<outbound-endpoint ref="CustomerResponses" transformer-refs="ThisToThat"/>
</flow>
</mule>
Other, more advanced things you may configure at this level:
-
Security Manager - Authenticates requests based on one or more security providers
-
Agents - Agents are typically used for cross-cutting concerns such as logging or management
-
Notifications - Allow you to be notified upon certain lifecycle events
-
Transaction Management - Mule transactions are configured on inbound endpoints, where an endpoint can be configured to start a new transaction or join an existing one.
-
Properties - Property placeholders, message properties, and system properties.
Global Configuration Settings
You can configure global configuration settings such as the default transaction timeout and default threading profile in the <configuration> element. For example:
<mule>
...
<configuration defaultTransactionTimeout="31337">
<default-threading-profile poolExhaustedAction="RUN"/>
...
</configuration>
Accessing the Configuration Programmatically
All Mule configuration is accessible from a single object: org.mule.api.config.MuleConfiguration. Configurations in a MuleConfiguration are set when a MuleContext is created. The object becomes immutable after it is started and can be accessed using the following:
// implement MuleContextAware to have the reference injected
MuleConfiguration configuration = context.getConfiguration();