Implementing & Deploying Domain project with Mulesoft

January 21, 2025

Introduction

Domain Project is used to create shared resources which can reuse across other projects who are referring to domain projects.

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.

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 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 refer across all the other projects or applications so you can run all the application on same port (i.e. 8081).

Creating Domain Project

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

Provide the Project Name, Select Mule Runtime and Finish.

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

Under Global Configuration Elements, Manage Modules->Modules-> Add HTTP connector From Exchange->Apply and Close 

 

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

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

 

 

mule-domain-config.xml

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 jar file at target folder in your 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.

 

 

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

Referring 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.

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

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 domain project is deployed on Mule Runtime before deploying Mule application otherwise it will fail the deployment.

Now you can run all your application 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, domain project will automatically start with Mule Application. You don’t need to start a domain project explicitly.

The Domain project is Deployed sucessfully.Now This common Domain project  can be refer across all the other projects or applications so you can run all the application on same port (i.e. 8081).

 

 




 


Share this blog

Never Miss A Single Update

Cikkert Technology

Cikkert Technology is an IT services consultancy helping organizations leverage Integration Technology to accelerate business outcomes.
Find Us

9375 E. Shea Blvd #100, Scottsdale, AZ 85260
(480) 269-6479
info@Cikkert.com