A domain project comes in handy when you want to share resources across different Mule projects in your hosted on-premise Mule Runtime.
In Mule Runtime 4, the resources that can be shared are:
- VM
- TLS Context
- JMS and JMS Caching Connection
- Database
- WMQ
- JBoss, Bitronix Transaction Manager
To create a new project in Anypoint Studio (I'm using 7.1):
Create a New -> Mule Domain Project
Mule-domain-config.xml will be automatically generated. The naming is fixed. Here is an example of the domain project structure:
Right click on the project root and open project Properties window. Double check that the runtime version is the one you want to use. I'm using Runtime 4.1.1
Open the configuration XML for mule-domain-config.xml
You can now start adding your global configuration elements.
In Anypoint Studio 7, there are some slight differences to take note of. Now, every module is simply a project dependency, managed by Maven. In order to add shared resources, you will need to take note of Maven dependencies in the pom.xml file.
Take a HTTP connector, for example. I want all projects hosted in a certain domain to use the same HTTP port listener. In order to do this, I need those projects to reference my global listener configuration.
Now, first of all I will like to make sure ALL dependencies for this connector is taken care of. I opted to refer to the pom.xml of my existing projects and copy the dependency.
Dependency for the HTTP connector:
In the mule-domain-config XML, I replicated the schema for xmlns:http namespace as below:
<?xml version="1.0" encoding="UTF-8"?> <domain:mule-domain xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:domain="http://www.mulesoft.org/schema/mule/ee/domain" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xsi:schemaLocation=" http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/ee/domain http://www.mulesoft.org/schema/mule/ee/domain/current/mule-domain-ee.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd "> <!-- configure here resource to be shared within the domain --> <http:listener-config name="HTTPS_LISTENER" doc:name="HTTP Listener config"> <http:listener-connection host="0.0.0.0" port="8081" /> </http:listener-config> </domain:mule-domain>
In the same file, I
have added my listener configuration here which listens on the port 8081.
Mule projects can
reference the domain easily by going to the project properties and selecting it
from the dropdown.
In my projects, I am
now able to see the HTTP_LISTENER config in the dropdown list.
Find out more about Studio 7 here:
Find out more about Studio 7 here:
Find out more about shared resources here:
5 comments:
Thanks for sharing valuable information it is useful to everyone
mulesoft training
Very informative post for mulesoft developers.You can also visit goformule.com for mulesoft stuff.
I really enjoyed reading your blog Thanks for sharing and it is very useful to everyone
Mulesoft Online Training
Mulesoft Training in Hyderabad
Thanks for sharing useful information.. we have learned so much information from your blog...
Mulesoft Training in Hyderabad
Mulesoft Online Training
Thanks for sharing info
Mulesoft Online Training
Mulesoft Online Training india
Post a Comment