Domain Project is used to create shared resources which can be reused 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.
Domain projects are more relevant to on-Prem installations where multiple apps run under one runtime and can share resources. Domain Project is concept in On Prem/Hybrid Application Deployments.
It is same as declaring global connector configuration but instead of sharing the configuration to single mule application, make it available across multiple applications. Every mule application deployed to Mule ESB can be associated to domain. One domain project may have multiple shared resources.
Mule allows you to define connectors and libraries in a Mule Domain, to which we can deploy different Mule applications. Domain based applications can share the resources configured in the domain to which they were deployed. With Domain support, MUnit allows you to test applications that run referencing a mule domain.
Example: In On-premise deployment, we deploy multiple applications on mule enterprise server. These types of deployments don’t support single ports for HTTP Listener for multiple applications. Thus, there is need to introduce HTTP Listener configuration as shared resources in Domain Project and use it throughout the deployed applications.
Steps to create Domain Project
- Create Mule Domain Project
- In Domain Project Settings , give project to be created name and click on finish.
- Add the Modules if not available through Manage Module. In our POC we are adding HTTP Module.
- Create a listener.
- Configure HTTP Listener for 8081 port.
- Now we are ready to create Mule Application using this Domain.
- Create Mule Project as per requirement
- Once Mule project is created, we need to configure it for Domain Project for shared resource configuration.
- Remove existing HTTP and Socket module from existing project (Because we will be using them from Domain Project).
- Now we need to add Domain project to our Mule application. For that go to properties and then to “Mule Project” and select the domain from drop down which you have created. Click on Apply and Close.
- Now, go to Listener and fetch the domain listener which you have configured in your flow. Make sure you also check configuration.xml for your listener after update.
- If you have multiple domain projects in Domain folder, then you need to make sure your application is always pointing to the correct one.
- Application is ready to be deployed and tested. Steps to Deploy application using domain project.
- Make sure the Mule ESB Server is up and running “C:\mule-ee-distribution-standalone-4.4.0\mule-enterprise-standalone-4.4.0”. Anchor file should be visible to you now.
- To make Domain Project available for on-Prem applications, we need to place Domain Project jar into “C:\mule-ee-distribution-standalone-4.4.0\mule-enterprise-standalone-4.4.0\domains”. So that it gets deployed first.
- We are ready to deploy our Mule applications now. Place mule application jar file into “C:\mule-ee-distribution-standalone-4.4.0\mule-enterprise-standalone-4.4.0\apps” and test the endpoint.
- In same way we can deploy multiple applications with same Domain Project and they will use same HTTP Listener configuration.
- Deployed 2 applications on same server:
- Now both the endpoints can be tested together:NOTE:
- If you have multiple mule projects to be deployed on-Prem, then you can use same domain project configuration for all, and now all your applications will be pointing to same listener and run on port 8081 (or port as per your configuration)
- You may also add TLS configuration to HTTP.
- Apart from HTTP Listener, you may also use other resources to share within your Mule Applications using Domain Project.
- 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.
- In Anypoint Studio you can run multiple mule applications together which are pointing to same Domain Project.