How to develop Domain Projects in MuleSoft?

on

|

views

and

comments

Domain Project

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.

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.

Limitations

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

Create a New Domain

In Studio, create a new Mule project in which to add and configure the connector:

  1. Select File > New > Mule Domain Project.
  2. Enter a name for your Mule Domain project and click Finish.

Now open mule-domain-config.xml file and add the global configuration element which you want to add. In our case we are going to add HTTP Listener Config

Add Modules in Domain Project

  • Right Click on domain project and then manage dependencies
  • Then select Manage Modules
  • Click on the + icon and then select features Modules or select mule exchange from where you wanted to download the module
  • Select the modules which you wanted to add and click on
  • Then click on apply and close

Create a Mule Project

In Studio, create a new Mule project in which to add and configure the connector:

  1. Select File > New > Mule Project.
  2. Enter a name for your Mule project and click Finish.
  3. Now open the configuration XML file and remove all the existing modules that are added to project
  4. To remove the module right click on the module and click on remove module
  5. Repeat no 4 for all the modules except Core & Favorites

Add Domain Project to Your Project

  • Right Click on the Project and select Properties
  • Then Select select Mule Project
  • Now select your project for Domain Picklist
  • Click on Apply & Close

Create Other Projects and Apply the Same Process to share the same resources as the domain project. I have created 2 projects which are sharing the same resource.

Configure a Source

  1. In the Mule Palette view, select HTTP > Listener.
  2. Drag Listener to the Studio canvas.
  3. You will see the connector configuration that you have created in the domain project
  4. On the Listener configuration screen, optionally change the value of the Display Name field.
  5. Specify a value for the Path field.

Add a Set Payload to the Flow

Add Set Payload component to canvas for both or all the applications that you have created. I have added the set payload which is returning “I am from Application 1 or Application 2” depending upon the application and the endpoint.

Run the Domain Project

  • Right click on Domain Project
  • Select Run As then select Run Configurations
  • Select All the Projects and Domain Project as well then click on run

You will see the outcome like below

Happy Learning #Mule4 #MuleSoft #MuleSoftDeveloper

Amit Singh
Amit Singhhttps://www.pantherschools.com/
Amit Singh aka @sfdcpanther/pantherschools, a Salesforce Technical Architect, Consultant with over 8+ years of experience in Salesforce technology. 21x Certified. Blogger, Speaker, and Instructor. DevSecOps Champion
Share this

Leave a review

Excellent

SUBSCRIBE-US

Book a 1:1 Call

Must-read

How to Utilize Salesforce CLI sf (v2)

The Salesforce CLI is not just a tool; it’s the cornerstone of development on the Salesforce Platform. It’s your go-to for building, testing, deploying, and more. As one of the most important development tools in our ecosystem

Save the day of a Developer with Apex Log Analyzer

Table of Contents What is Apex Log Analyzer? Apex Log Analyzer, a tool designed with Salesforce developers in mind, is here to simplify and accelerate your...

Salesforce PodCast

Introduction Hey Everyone, Welcome to my podcast, the first-ever podcast in India for Salesforce professionals. Achievement We are happy to announce that we have been selected as Top...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here

5/5

Stuck in coding limbo?

Our courses unlock your tech potential