31
Sharing resources with Mule By Anirban Sen Chowdhary

Sharing resources with mule

Embed Size (px)

Citation preview

Page 1: Sharing resources with mule

Sharing resources with MuleBy Anirban Sen Chowdhary

Page 2: Sharing resources with mule

We often require to share a resource within multiple application or multiple project.For example, we can share our resources like HTTP, VM, JMS or any other connector among multiple Mule application and can use within those different application.

Page 3: Sharing resources with mule

How can share our resource between multiple Mule application ???

Page 4: Sharing resources with mule

Mule has the ability to select a connectors as common resources and expose them to all applications deployed under a same domain. We need to create a domain under which resources can be shared.These resources are known as Shared resources, and to host these we need create a Mule Domain Project and then add reference to it on each of the projects. Once we define, any Mule application associated with a particular domain can access resources.

This idea of Shared resources allows multiple development teams to work in parallel using the same set of reusable connectors.

Page 5: Sharing resources with mule

Creating a domain to share resources.

Page 6: Sharing resources with mule

We start with creating a Mule Domain project first in our Anypoint studio.

Page 7: Sharing resources with mule

Let’s give the project name as Shared_Domain_Project1

Page 8: Sharing resources with mule

And now we will ad a resource, for example a HTTP connector that will be shared across multiple application.Here we can see we have used the connector name as HTTP_Shared_Listener and this will be shared among multiple application.

Page 9: Sharing resources with mule

Adding an application in the domain

Page 10: Sharing resources with mule

Now we will add application in the domain called shared_domain_project1. This application will reuse the shared HTTP connector called HTTP_Shared_Listener_Configuration. We will call it as application1.

Page 11: Sharing resources with mule

We will create a flow in the application that will refer shared HTTP connector HTTP_Shared_Listener_Configuration

Page 12: Sharing resources with mule

Lastly, we will associate our application1 with the domain shared_domain_project1 we created in our mule-project.xml of our application

Page 13: Sharing resources with mule

Adding another application in the domain

Page 14: Sharing resources with mule

We will now add another application in the same domain called shared_domain_project1. This application will also reuse the shared HTTP connector called HTTP_Shared_Listener_Configuration. We will name it as application2.

Page 15: Sharing resources with mule

We will again repeat the same and create a flow for the application2 that will refer shared HTTP connector HTTP_Shared_Listener_Configuration

Page 16: Sharing resources with mule

Repeating the same process, we will associate our application2 with the domain shared_domain_project1 we created in our mule-project.xml of our application.

Now, both of our application are associated with same domain and will share the same HTTP connector.

Page 17: Sharing resources with mule

Deploying our domain and associated applications

Page 18: Sharing resources with mule

We will select our domain project and will select Run As Run Configuration

Page 19: Sharing resources with mule

We can see, by default the domain is associated with both the application. We can manually select the application we want to deploy with this domain. In our case, we will deploy both.

Page 20: Sharing resources with mule

Testing our domain applications

Page 21: Sharing resources with mule

We can see, the domain and it’s both applications has been deployed successfully.

Page 22: Sharing resources with mule

So, if we hit url :- http://localhost:8081/app1 which is used by application1 in the domain, we will find the following results in the browser:-

Page 23: Sharing resources with mule

And if we hit url :- http://localhost:8081/app2 which is used by application2 in the domain, we will find the following results in the browser:-

So, we can clearly see here both the application is using the same HTTP connector among them.

Page 24: Sharing resources with mule

Testing our domain applications on Standalone server

Page 25: Sharing resources with mule

To, deploy the domain in Mule Standalone server, we need to create the .zip file of the domain project and put it MULE_HOME/domains folder, then it deploys the application

Page 26: Sharing resources with mule

Now, the best part is we will see our Domain is deployed successful and not only that, both the applications associated with it is automatically deployed :-

Page 27: Sharing resources with mule

If we got to our MULE_HOME/domains folder location, we will see that the domain got deployed and it created an anchor.txt file with the successful deployment :-

Page 28: Sharing resources with mule

Also if we got to our MULE_HOME/apps folder location, we will both our applications associated with it deployed and both have created an anchor.txt file with the successful deployment :-

We can now test the applications again in the same way we did it with our Studio.

Page 29: Sharing resources with mule

Conclusion…..

Page 30: Sharing resources with mule

Here it was a small demonstration to share a resources among multiple applications. Apart from HTTP,we can do it for other resources like VM, JMS, Database, WMQ, Jboss Transaction Manager and many more.

So at the end I can only say that, let’s spread our knowledge and expand our Mule community.

Page 31: Sharing resources with mule

Thank You