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:
- Select File > New > Mule Domain Project.
- 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:
- Select File > New > Mule Project.
- Enter a name for your Mule project and click Finish.
- Now open the configuration XML file and remove all the existing modules that are added to project
- To remove the module right click on the module and click on remove module
- 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
- In the Mule Palette view, select HTTP > Listener.
- Drag Listener to the Studio canvas.
- You will see the connector configuration that you have created in the domain project
- On the Listener configuration screen, optionally change the value of the Display Name field.
- 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