DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report

Shared Resources and Mule Domain Project

In Mule, you can share resources among your different projects by creating a domain project, allowing access to elements from all projects with that domain name.

Tirapa Reddy Tondapu user avatar by
Tirapa Reddy Tondapu
·
Jun. 09, 17 · Tutorial
Like (5)
Save
Tweet
Share
22.39K Views

Join the DZone community and get the full member experience.

Join For Free

Why Mule Domain Project?

A Mule Domain project is used to configure shared resources so these shared resources can be accessed from different Mule projects associated with this domain project. Once we create and deploy a domain project, a domain is created with the project name, so you can configure this domain in your application either by using mule-deploy.properties file or by using mule-project.xml so that all the resources configured in it can be accessed.

What Are Shared Resources?

Mule supports the ability to define selected connectors as common resources and expose them to all applications deployed under the same domain. These resources are known as shared resources; to host these, you must create a Mule Domain Project and then reference it on each of the projects that are meant to use the elements in it. Once defined, any Mule application associated with a particular domain can access resources in this file. Note that Mule applications 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 applications through a well-defined interface,
  • Ensure consistency between applications upon any changes, as the configuration is only set in one place.

Requirements

This document assumes that you are using Anypoint Studio with Mule runtime 3.6 or newer, or that you are building your applications outside Studio and deploying them to Mule Standalone 3.5.0 runtime or newer.

Creating a Mule Domain Project

Open Anypoint Studio, and Click on "File" ===> click on "New" ===> select and click on "Mule Domain Project" and then enter your domain project name as shown in the attached screenshot.

Image title

Once you have created this domain project, the structure of the project looks like this:

Structure

As you have created the domain project with the name "first-mule-domain-project," you can now configure "Shared Resources" in this project. I'm going to create a "Http Listener" Shared Resource in this project so that it can be accessed from my other Mule projects.

To create a Shared Resource in our domain project, we need to configure (or copy and paste) the corresponding resource's schemaLocation and its namespaces in our domain project. As I'm going to configure the HTTP Listener as a Shared Resource, I need to configure the below schemaLocation and namespace in my domain project's "mule-domain-config.xml," file as shown in the below screenshot.

For namespace use: xmlns:http="http://www.mulesoft.org/schema/mule/http 

For schemaLocation use: http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd Image title

As you have created a configured namespace and schemaLocation, now you will be able to configure the below Http Listen in your domain project:

<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="9876" doc:name="HTTP Listener Configuration"/>

This is an HTTP listener; you can refer to this from any of your Mule projects associated with this domain (first-mule-domain-project).

Image title

Once you run your domain project, the domain will be registered with your Mule runtime so you can refer to this domain from your project.

Referring to Shared Resources in Your Mule Project

Here you have two options to refer to the resource from your Mule project:

  1. Using the mule-deploy.properties file.

  2. Using the mule-project.xml file.

Using mule-deploy.properties

Here, you open the mule-deploy.properties file and configure the domain properties value as "first-mule-domain-project" as shown in the below figure.

Image title

Using mule-project.xml

Click on mule-project.xml; then you will be able to see a list of all domains available in your Mule ESB and you can select the domain "first-mule-domain-project" as shown below.

Image title

As you have associated your Mule project named "object-store" with the domain "first-mule-domain-project," you can now access the HTTP listener shared resource named "HTTP_Listener_Configuration" from your project, as shown below.

Image title

In my project named "object-store," I didn't create that HTTP listener for my HTTP inbound connector, but I was able to access "HTTP_Listener_Configuration" from my Mule domain project.

I hope this helps you understand shared resources and Mule domain project.

application Shared resource

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Java Concurrency: LockSupport
  • Demystifying Multi-Cloud Integration
  • OpenVPN With Radius and Multi-Factor Authentication
  • Strategies for Kubernetes Cluster Administrators: Understanding Pod Scheduling

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: