Shared Resources

Standard Support for Mule 4.1 ended on November 2, 2020, and this version of Mule will reach its End of Life on November 2, 2022, when Extended Support ends.

Deployments of new applications to CloudHub that use this version of Mule are no longer allowed. Only in-place updates to applications are permitted.

MuleSoft recommends that you upgrade to the latest version of Mule 4 that is in Standard Support so that your applications run with the latest fixes and security enhancements.

When you deploy Mule on premises, you can define global configurations such as default error handlers, shared properties, scheduler pools, and connector configurations to be shared among all applications deployed under the same domain. To do so, create a Mule domain and then reference it from each application. As a result, each app now associated with the Mule domain can access shared resources in the domain.
Note that Mule apps are associated with only one domain at a time.

Sharing resources allows multiple development teams to work in parallel using the same set of connector configurations, enabling the teams to:

  • Expose multiple services within the domain through the same port.

  • Share the connection to persistent storage.

  • Share services between Mule applications through a well-defined interface.

  • Ensure consistency between Mule applications upon any changes because the configuration is only set in one place.

To share the metadata, keep the Mule domain project open in Anypoint Studio. Otherwise, you must enter the metadata manually on the linked Mule projects.


  • Anypoint Studio 7.x

  • Mule runtime engine 4.x

  • Run Mule runtime engine On Premises


Defining flows, subflows, or any message processors as shared resources is not supported. Domains are not meant to share behavior. They are meant to share resources only.


A Mule domain project in Anypoint Studio has the following key files:

File Name Description


This is the shared resources configuration file. This file must have the mule-domain-config.xml file name.


This is the dependencies file descriptor. It is a Maven POM file with required plugins for domains projects.


This file is a descriptor for the domain artifact.

When you package the Mule domain project into a deployable JAR file, you can find the following files:

File Name Description


This is the shared resources configuration file. This file must have the mule-domain-config.xml file name.


A Maven-like repository with all the dependencies of the domain.


Artifact Maven descriptor file.


Internal Mule file used for dependency management.


This file is a descriptor for the domain artifact.

Creating a New Domain

To create a new domain in Anypoint Studio:

  1. In the top menu bar select, File > New > Mule Domain Project.

  2. Fill in the same fields as you would with a regular Mule Project:

    • Provide a name for the project, and select a Mule version.

Defining Shared Resources

You can configure the domain project by defining shared resources in your mule-domain-config.xml file. You can define multiple resources in this configuration file. In Anypoint Studio, you can edit this file in a couple of ways:

  • Configuration file: Through the XML similar to the XML configuration file for a Mule app, for example:

    <?xml version="1.0" encoding="UTF-8"?>
                   http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
                   http://www.mulesoft.org/schema/mule/ee/domain http://www.mulesoft.org/schema/mule/ee/domain/current/mule-domain-ee.xsd">
        <!-- configure here resource to be shared within the domain -->
  • Global Elements: This view provides a graphical interface for defining shared resources.

You can add module or connector dependencies to you domain project so you can use them as shared resources.

Associating Applications with a Domain

Mule apps can be associated with only one domain at a time. You can associate an existing Mule app with a domain either by using Studio or by editing your project’s pom.xml file directly. If you don’t set a domain dependency, Mule applications use the default domain.

Consider the following when working with Mule 4.2.2 and later versions:

  • The version honors semantic versioning.
    For example, if you set the version to 1.0.1, a domain with version 1.0.2 and later works, but a domain with version 1.0.0 does not.

  • If different domains are deployed with the same group ID, artifact ID, and version, the reference in the pom.xml file might be ambiguous.
    To avoid this issue, add the name of the domain folder in the Mule application’s mule-artifact.json file:

  "domain": "mymuledomain-1.0.1-mule-domain"

Associate a Mule App with a Domain Using Studio

To associate a Mule application with a domain from Studio, follow these steps:

  1. In the Project Explorer or Package Explorer view, right-click the Mule application.

  2. In the menu that opens, click Properties.

  3. From Properties, click Mule Project.

  4. In the Domain field, select a domain for your project.


    Note that when you select a domain, the Mule runtime engine for your project matches the domain’s Mule runtime engine automatically.

After completing these steps, Studio includes the domain in the pom.xml for your project, for example:


Associate a Mule App with a Domain Outside Studio

To associate a Mule app with a domain outside Studio, add the domain dependency to the pom.xml file as shown in the previous example.

Referencing Shared Resources

The following mule-domain-config.xml example defines HTTP listener and HTTP request configurations as shared resources.

<?xml version="1.0" encoding="UTF-8"?>
<mule-domain xmlns="http://www.mulesoft.org/schema/mule/domain"
               http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
                     http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
               http://www.mulesoft.org/schema/mule/domain http://www.mulesoft.org/schema/mule/domain/current/mule-domain.xsd">

    <http:listener-config name="HTTP_Listener_Configuration">
        <http:listener-connection host="" port="8080"/>

    <http:request-config name="domainLevel">
        <http:request-connection host="localhost" port="9090"/>


Any Mule application associated with the domain can make use of the shared resources by referencing them within the configuration in the same way that you reference a resource within the project itself. In the example that follows, the HTTP Listener connector references the shared resource named HTTP_Listener_Configuration.

   <flow name="httpService">
      <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
      <set-payload value="success" />

In Studio’s visual editor, you can simply pick the shared resource out of the dropdown list in the Connector Configuration field of the connector’s properties editor:


Deploying with Shared Resources

By default, when you deploy either a Mule application associated with a domain or a domain associated with any Mule application, Anypoint Studio deploys both. You can change this default behavior by changing the run configuration for the domain. You can also deploy a set of Mule applications in your workspace together, even if they don’t share the same domain.

Mule domain projects cannot be installed using Runtime Manager.

Deploy from Anypoint Studio

The following steps describe how to deploy your domain project and the associated Mule applications from Studio:

  1. Open the drop-down menu next to the play button and select Run Configurations.

  2. Select the General tab and then select the boxes next to the projects that you want to always deploy together with the Mule application that is currently selected in the navigation menu to the right.


Deploy Outside Anypoint Studio

The following steps describe how to deploy your domain project and the Mule applications outside Studio, to a standalone Mule runtime engine:

  1. In Studio, select File > Export.

  2. Select Mule > Anypoint Studio Project to Mule Deployable Archive (includes Studio metadata).
    This process creates a JAR file that you can deploy to a standalone Mule runtime engine.

    mruntime export studio
  3. Copy the exported domain’s JAR file to MULE_HOME/domains.

  4. Export each Mule application that you want to deploy with the associated domain.

  5. Copy the exported JAR files for each Mule application that references the domain into the MULE_HOME/apps folder.

  6. Start Mule via the command console.

    When Mule starts, it first deploys any domains found in the MULE_HOME/domains folder, then it deploys the Mule applications in the MULE_HOME/apps folder, so that all domains are fully started before the Mule applications start.

Deploying Domains Using Mule Maven Plugin

You can deploy domains to your local Mule instances using the Mule Maven plugin. See Deploy a Domain for instructions.

Was this article helpful? Thanks for your feedback!
View on GitHub