DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • MuleSoft Integration With RabbitMQ
  • How to Use Mulesoft VM Connector
  • Mule 4 Custom Policy Example
  • Build a Java Backend That Connects With Salesforce

Trending

  • A System Cannot Protect What It Does Not Understand
  • Building an Image Classification Pipeline With Apache Camel and Deep Java Library (DJL)
  • Multi-Scale Feature Learning in CNN and U-Net Architectures
  • Building a Skill-Based Agentic Reviewer with Claude Code: A Practical Guide Using Skills.MD, MCP Servers, Tools, and Tasks
  1. DZone
  2. Data Engineering
  3. Data
  4. Implementing and Deploying the Domain Project With MuleSoft

Implementing and Deploying the Domain Project With MuleSoft

Shared resources allow multiple development teams to work in parallel using the same set of reusable connectors.

By 
Jitendra Bafna user avatar
Jitendra Bafna
·
Feb. 19, 20 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
19.7K Views

Join the DZone community and get the full member experience.

Join For Free

Introduction

Domain Project is used to create shared resources that can be reused.

Mule can define selected connectors as common resources and expose them to all apps deployed under the same domain. These resources are known as shared resources. To host them, you must create a Mule Domain Project and then reference it from each of the projects that use the elements in it. Once defined, any Mule app associated with a particular domain can access resources in this file. Note that Mule apps can be associated with only one domain at a time.

You may also like: Mule Domain Project and Deploying Domain Project in Mule Standalone Server

Shared resources allow multiple development teams to work in parallel using the same set of reusable connectors. Defining these connectors as shared resources at the domain level allows the team to:

  • Expose multiple services within the domain through the same port.
  • Share the connection to persistent storage.
  • Share services between apps through a well-defined interface.
  • Ensure consistency between apps 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.

Use Case

Generally, when you deploy the application having HTTP Listener on mule standalone run time, each application needs to be deployed on different ports otherwise you will get an error.

To avoid this, you can implement the domain project and define HTTP Listener connection with some port (i.e. 8081) and that domain project can be referred across all the other projects or applications so you can run all the applications on the same port (i.e. 8081).

Creating Domain Project

To create domain projects using Anypoint Studio, Go To File -> New -> Mule Domain Project.

mule domain project

Provide the Project Name, Select Mule Runtime, and Finish.

common-domain

After Finish, we will define the HTTP Listener with port 8081 in mule-domain.config.xml.

Under Global Configuration Elements, Select Create -> Connector Configuration -> HTTP Listener config.

choose global type

Under HTTP Listener config, set Port to 8081. Click OK.

http (default)

mule-domain-config.xml

XML
 




x
15


 
1
<?xml version="1.0" encoding="UTF-8"?>
2
<domain:mule-domain
3
        xmlns:http="http://www.mulesoft.org/schema/mule/http"
4
        xmlns="http://www.mulesoft.org/schema/mule/core"
5
        xmlns:domain="http://www.mulesoft.org/schema/mule/ee/domain"
6
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7
        xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xsi:schemaLocation="
8
               http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
9
               http://www.mulesoft.org/schema/mule/ee/domain http://www.mulesoft.org/schema/mule/ee/domain/current/mule-domain-ee.xsd
10
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
11
    <http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="713eacdb-c363-48a7-88e6-08191fd34541" >
12
        <http:listener-connection host="0.0.0.0" port="8081" ></http:listener>
13
    </http:listener-config>
14
    <!-- configure here resource to be shared within the domain -->
15
</domain:mule-domain>



Building Domain Project

To build a domain project, use command mvn clean install.

Go to the path where domain project exists on command prompt and run maven command to build it. It will generate a jar file at the target folder in your domain project (i.e. common-domain-1.0.0-SNAPSHOT-mule-domain.jar).

building domain project

Deploying the Domain Project

To deploy a domain project, copy the jar file which has been built above at $MULE_HOME/domains and as soon you copy the file to that location, it will automatically unzip the jar file.

common-domain

Before copying the jar file, you need to make sure your mule runtime is running.

Referring to the Mule Domain Project in Mule Application

To Refer domain project in Mule Application, you need to make sure domain project and mule application both exist in Anypoint Studio.

Right, Click on Mule Application -> Properties -> Mule Project, Select Domain project and Apply and Close.

hello-world-application

Now you can see HTTP Listener config defined in the domain project can be used in Mule Application (i.e. hello-world-application).

hello-world-applicationFlow

HTTP_Listener_config populated from domain project. This is how you can refer domain projects to multiple mule applications to reuse HTTP Listener Config for port 8081.

You need to make sure the domain project is deployed on Mule Runtime before deploying Mule application otherwise it will fail the deployment.

Now you can run all your applications having HTTP Listener on port 8081 by referring to domain project HTTP Listener Config.

Running Mule Application and Domain Project With Anypoint Studio

Once you start running the Mule Application, the domain project will automatically start with Mule Application. You don't need to start a domain project explicitly.

hello world!

Now, you know how to implement and deploy Domain Project With MuleSoft.

application MuleSoft app Connector (mathematics) JAR (file format) Use case Command (computing) teams Metadata

Opinions expressed by DZone contributors are their own.

Related

  • MuleSoft Integration With RabbitMQ
  • How to Use Mulesoft VM Connector
  • Mule 4 Custom Policy Example
  • Build a Java Backend That Connects With Salesforce

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook