Introduction
The video for this blog is available at:
http://www.youtube.com/watch?v=wVCmik-2xAM&feature=youtu.be
Mule and JBoss Fuse ESBs are most popular open source ESBs on the market. They are the leaders. I have been working with both for numerous years. Both of them have their strengths and weakness. I discuss these further in my later blog. Today, I am going to describe Mule 101 from development point of view. I am going to cover the following aspects:
- Install Mule Studio
- Install Mule MMC and Runtime
- Develop Hello World Mule Application
- Build Mule Project With Maven
- Mule Application Deployment
Install Mule Studio
You can download both Mule Studio and MMC from http://www.mulesoft.com/platform/soa/mule-esb-enterprise. You will need to fill a form so that Mule can track you down, and hopefully you will buy their product. I downloaded the following two file to ~/Downloads on my MacBook:
1 2 | mmc-distribution-mule-console-bundle-3.4.2.zip MuleStudio- for -macosx-64bit-3.5.0-201312091746.zip |
As you can see the current mule run time is version 3.4.2 and Mule Studio is 3.5. Execute the following commands [My current dir is ~/Downloads]:
1 2 3 4 | jar vxf mmc-distribution-mule-console-bundle-3.4.2.zip jar vxf MuleStudio- for -macosx-64bit-3.5.0-201312091746.zip mv MuleStudio ~/. mv mule-enterprise-standalone-3.4.2 ~/. |
Now, I have both Mule Studio and runtime under my home directory. Let's develop a Hello World Application.
Develop Hello World Mule Application
Start MuleStudio.app [Make sure it is executable]. Enable the maven setting by editing the Preferences as shown below:
To create a mule project, New -> Mule Project. Make sure create maven project as shown below:
As shown below, the MuleStudio will create a project with the following structures.
Now let's develop a simple application using HTTP component. Perform the flowing actions:
- Double click the mule flow file under flow directory
- Drag and drop the HTTP component
- Drag and drop the Logger component
- Double click the Logger icon in side the flow
- Fill the groovy script as shown below
1 2 3 4 5 6 7 8 9 10 | <!--xml version= "1.0" encoding= "UTF-8" ?--> <mule xmlns:http= "http://www.mulesoft.org/schema/mule/http" xmlns= "http://www.mulesoft.org/schema/mule/core" xmlns:doc= "http://www.mulesoft.org/schema/mule/documentation" xmlns:spring= "http://www.springframework.org/schema/beans" version= "EE-3.4.1" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation= "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd" > <flow name= "hello-worldFlow1" doc:name= "hello-worldFlow1" > <http:inbound-endpoint exchange-pattern= "request-response" host= "localhost" port= "8081" path= "echo" doc:name= "HTTP" > <logger message= "#[groovy:return message.toString();]" level= "INFO" doc:name= "Logger" > </logger></http:inbound-endpoint></flow> </mule> |
Now, we can run the mule application inside the studio by right click the the file hello-world.mflow file, run as, Muel application. You should see the following output in the studio console:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | NFO 2014-02-15 14:33:05,294 [main] org.mule.module.management.agent.JmxAgent: Registered Connector Service with name Mule.hello-world:type=Connector,name= "connector.http.mule.default.1" INFO 2014-02-15 14:33:05,297 [main] org.mule.DefaultMuleContext: ********************************************************************** * Application: hello-world * * OS encoding: US-ASCII, Mule encoding: UTF-8 * * * * Agents Running: * * Clustering Agent * * JMX Agent * ********************************************************************** INFO 2014-02-15 14:33:05,297 [main] org.mule.module.launcher.MuleDeploymentService: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Started app 'hello-world' + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 | http: //localhost:8081/echo?UserName=Gary Liu |
1 | /echo?UserName=Gary%20Liu |
At this point, we have created a simple mule application using HTTP and Logger components coming with mule. This process is good for development and unit testing. However, we normal build the application using maven and later perform continuous integration using other utility like Jenkins. Now, let me explain the build process using maven.
Build Mule Application With Maven
In order to build maven project created through MuleStudio, we need to uncomment all the following dependencies:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | <!-- <dependency> <groupId>com.mulesoft.muleesb.modules</groupId> <artifactId>mule-module-boot-ee</artifactId> <version>${mule.version}</version> <scope>provided</scope> </dependency> --> <!-- <dependency> <groupId>com.mulesoft.muleesb</groupId> <artifactId>mule-core-ee</artifactId> <version>${mule.version}</version> <scope>provided</scope> </dependency> --> <!-- <dependency> <groupId>com.mulesoft.muleesb.modules</groupId> <artifactId>mule-module-spring-config-ee</artifactId> <version>${mule.version}</version> <scope>provided</scope> </dependency> --> <!-- <dependency> <groupId>com.cloveretl</groupId> <artifactId>cloveretl-engine</artifactId> <version>${mule.version}</version> <scope>test</scope> </dependency> --> |
One more thing before we can build using maven. Execute the folloing script under MuleStudio installation dir [~/MuleStudio]. This is to install licm jar file to our local maven repo.
1 2 3 4 5 6 | mvn install:install-file \ -Dfile=plugins/org.mule.tooling.server.3.4.1.ee_3.4.1.201312062152/mule/plugins/mule-plugin-debugger-3.4.1/lib/licm-1.1.3.jar \ -DgroupId=com.mulesoft.licm \ -DartifactId=licm \ -Dversion=1.1.3 \ -Dpackaging=jar |
Now, we can build the Hello World mule application we just developed. Let's do the following:
1 2 | cd ~/MuleStudio/workspace/hello-world mvn clean install |
The maven build process takes now time. If you check the target directory, there is a file named as: hello-world-1.0.0-SNAPSHOT.zip. This is the file we will deploy to the mule runtime. If you are curious enough and wander what are the contents inside that zip file, you can do the following:
1 2 3 4 5 6 7 8 9 10 | [/Users/Gary2013/MuleStudio/workspace/hello-world]$ cd target [/Users/Gary2013/MuleStudio/workspace/hello-world/target]$ jar vtf hello-world-1.0.0-SNAPSHOT.zip 989 Sat Feb 15 14:33:02 CST 2014 hello-world.xml 0 Sat Feb 15 14:14:20 CST 2014 mule-app.properties 119 Sat Feb 15 14:33:02 CST 2014 mule-deploy.properties 0 Sat Feb 15 15:01:22 CST 2014 classes/ 989 Sat Feb 15 15:01:22 CST 2014 classes/hello-world.xml 0 Sat Feb 15 15:01:22 CST 2014 classes/mule-app.properties 119 Sat Feb 15 15:01:22 CST 2014 classes/mule-deploy.properties [/Users/Gary2013/MuleStudio/workspace/hello-world/target]$ |
This is the beauty about mule. Its application is very clean and minimum comparing with osgi bundles. Mule will be able to figure out dynamically what jar files should be linked during runtime. Once the application zip file is build, we can deploy it to the mule runtime.
Mule Application Deployment
There is a README.txt file under mule runtime installation [in my case, it is ~/mule-enterprise-standalone-3.4.2]. In that will, the start, stop and restart procedures are described. Let's start the mule as daemon by run the following command:1 2 3 4 | [/Users/Gary2013/mule-enterprise-standalone-3.4.2]$ bin/mule start MULE_HOME is set to /Users/Gary2013/mule-enterprise-standalone-3.4.2 Starting Mule Enterprise Edition... [/Users/Gary2013/mule-enterprise-standalone-3.4.2]$ |
Now, we can check what java process is mule runtime. Here is what I see:
1 2 3 | [/Users/Gary2013/mule-enterprise-standalone-3.4.2]$ ps -eaf | egrep java | egrep -v egrep 501 17266 17265 0 3:19PM ?? 0:32.28 /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/bin/java -Dmule.home=/Users/Gary2013/mule-enterprise-standalone-3.4.2 -Dmule.base=/Users/Gary2013/mule-enterprise-standalone-3.4.2 -Djava.net.preferIPv4Stack=TRUE -XX:MaxPermSize=256m -Djava.endorsed.dirs=/Users/Gary2013/mule-enterprise-standalone-3.4.2/lib/endorsed -Xmx1024m -Djava.library.path=%LD_LIBRARY_PATH%:/Users/Gary2013/mule-enterprise-standalone-3.4.2/lib/boot -classpath %MULE_LIB%:/Users/Gary2013/mule-enterprise-standalone-3.4.2/conf:/Users/Gary2013/mule-enterprise-standalone-3.4.2/lib/boot/commons-cli-1.2.jar:/Users/Gary2013/mule-enterprise-standalone-3.4.2/lib/boot/commons-codec-1.3-osgi.jar:/Users/Gary2013/mule-enterprise-standalone-3.4.2/lib/boot/jul-to-slf4j-1.6.1.jar:/Users/Gary2013/mule-enterprise-standalone-3.4.2/lib/boot/licm-1.1.4.jar:/Users/Gary2013/mule-enterprise-standalone-3.4.2/lib/boot/log4j-1.2.16.jar:/Users/Gary2013/mule-enterprise-standalone-3.4.2/lib/boot/mule-module-boot-ee-3.4.2.jar:/Users/Gary2013/mule-enterprise-standalone-3.4.2/lib/boot/mule-module-logging-3.4.2.jar:/Users/Gary2013/mule-enterprise-standalone-3.4.2/lib/boot/oscore-2.2.4.jar:/Users/Gary2013/mule-enterprise-standalone-3.4.2/lib/boot/propertyset-1.3.jar:/Users/Gary2013/mule-enterprise-standalone-3.4.2/lib/boot/truelicense-1.29.jar:/Users/Gary2013/mule-enterprise-standalone-3.4.2/lib/boot/truexml-1.29.jar:/Users/Gary2013/mule-enterprise-standalone-3.4.2/lib/boot/wrapper-3.5.19.jar:/Users/Gary2013/mule-enterprise-standalone-3.4.2/data-mapper -Dwrapper.key=d4wYZG88GHn1riyEuxVDypA4M4y9i5w4 -Dwrapper.port=32000 -Dwrapper.jvm.port.min=31000 -Dwrapper.jvm.port.max=31999 -Dwrapper.disable_console_input=TRUE -Dwrapper.pid=17265 -Dwrapper.version=3.5.19-st -Dwrapper.native_library=wrapper -Dwrapper.arch=universal -Dwrapper.service=TRUE -Dwrapper.cpu.timeout=10 -Dwrapper.jvmid=1 -Dwrapper.lang.domain=wrapper -Dwrapper.lang.folder=../lang org.mule.module.reboot.MuleContainerBootstrap start0 [/Users/Gary2013/mule-enterprise-standalone-3.4.2]$ |
The deployment procedure is covered pretty well http://www.mulesoft.org/documentation/display/current/Application+Deployment. Simple, we can copy the zip file from target to the apps directory.
1 | cp ~/MuleStudio/workspace/hello-world/target/hello-world-1.0.0-SNAPSHOT.zip . |
Mule has a feature called hot-deployment. Once the zip file is dropped to the apps dir, mule will unzip the archive, delete it, and create a file named like: hello-world-1.0.0-SNAPSHOT-anchor.txt. Inside that file, there is a line of text. The meaning of text is not important. Mule is just using it as key to monitor the application. To undeploy the application, you can simply delete the anchor file.
This comment has been removed by the author.
ReplyDeletethanks a lot ..it would ve been better if u were a bit little more basic (simple step by step) so that a fresher or a beginer like me can cope up good
ReplyDeleteThis was very good. I'm not sure what you could've done to make it "a bit little more basic". I've encountered a problem with v5.4 (rebranded to Anypoint), where the inbound-endpoint has been deprecated and we're supposed to use http:listener. I've tried to follow your guide as much as I can, but the logger message is not being returned by the listener. I'll try to post an update if I figure it out.
ReplyDeleteThis comment has been removed by the author.
DeleteEdit: It appears that the http:listener requires the use of a set-payload transformer to obtain the response value to be returned. The logger element is not a valid subelement of an http:listener and cannot set the payload for the response. Indeed, the logger element logs whatever is set in the message property to the console for logging purposes.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteGregS - I am new to mule and was started by this example, i just cant get the response in the browser, though my lister is running and it captures logging details in console.
ReplyDelete------------------
-----------------
ReplyDelete--i created this but not getting response back, my app starts fine and logs what I pass in input:
http://localhost:8081/?UserName=Nishan
This comment has been removed by the author.
ReplyDeletehave u tried XML to JASON element from mule studio instead of using the transformer element ? what is the use of this element ? and do u have a sample ?
ReplyDeleteDataweave is the most powerful tool for transform different data types, from xml to json, csv to json, json to xml etc.
DeleteIm asking about this element
ReplyDeleteI have two video tutorial on DataWeave on YouTube. Let me know if that will help
Deletehow to call mule flow using java client
ReplyDeleteHi Buddy,
DeleteNice to be visiting your blog again, it has been months for me. Well this article that i’ve been waited for so long.
MuleSoft is the most recent "unicorn" to petition for an IPO. The organization, which enables organizations to like Netflix and Spotify with their APIs, has revealed its financials to people in general in a S-1 recording, recommending that they are focusing on a presentation when March.
The span of the proposed IPO is $100 million, yet that is liable to change.
Very useful post !everyone should learn and use it during their learning path.
Kind Regards,
Xin chào GAry Liu
ReplyDeleteMy name is Tuan Khanh, I am Vietnamese. I watched your video clip about MULE, it's great. I am doing a MULE exercise but I have not done it yet, hope you help. Thank you very much. You give me the address EMAIL.
You wrote an excellent article thank you for sharing Mulesoft online training
ReplyDeleteThe article was very clear and it's usefull information Mulesoft Online Training Hyderabad
ReplyDeleteThank you for sharing such detailed article.
ReplyDeleteMulesoft Online course India
This article was very helpful Mulesoft Online Training Hyderabad
ReplyDeleteThis helps the readers a lot Mulesoft Online Training Bangalore
ReplyDeleteVery Good informative Article Mulesoft Online Training Bangalore
ReplyDeleteThank you so much for sharing with us. Appreciate them, Mulesoft Online Training Hyderabad
ReplyDelete
ReplyDeleteThat is very interesting; you are a very skilled blogger. I have shared your website in my social networks! A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article.
Mulesoft online training
Very Good informative Article Mulesoft Online Training Hyderabad
ReplyDeleteIam very impressive your site gives the best and the most interesting information. This is just the kind of information that i had been looking for, i'm already your rss reader now and i would regularly watch out for the new posts, once again hats off to you..
ReplyDeleteMulesoft online training bangalore
Very informative post! There is a lot of information here that can help
ReplyDeleteDot Net Online Training Hyderabad
the blog is about Gary Liu's Technical Knowledge Base it is useful for students and Mulesoft Developers for more updates on Mulesoft follow the link
ReplyDeletemulesoft Online Training
For more info on other technologies go with below links
Python Online Training
tableau online training hyderabad
ServiceNow Online Training
the blog is good and Interactive it is Introduce Mule ESB it is useful for students and Mulesoft Developers for more updates on Mulesoft
ReplyDeletehttps://onlineitguru.com/mulesoft-online-training.html
Howdy would you mind sharing which blog platform you're working with? I'm going to start my own blog soon but I'm having a hard time choosing between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design seems different then most blogs and I'm looking for something unique. P.S My apologies for being off-topic but I had to ask! it services melbourne
ReplyDeletethe blog is good and Interactive it is about Mulesoft Developer it is useful for students and Mulesoft Developers for more updates on Mulesoft mulesoft Online course
ReplyDeleteInteresting stuff which is helpful..
ReplyDeleteJust an important heads up you can get more details by following this blog which was quite helpful for me.
Mulesoft Introduction
Hi There,
ReplyDeleteGasping at your brilliance! Thanks a tonne for sharing all that content. Can’t stop reading. Honestly!
User management and provisioning have always been tedious and time-consuming tasks for IT professionals. If you’ve seen any of my blog posts before, you’ll know that there are two things I like: exposés in the form of parentheses and removing tedious manual work.
Naturally, this meant I ended up trying to solve user management
. One of the first questions I asked when I started addressing this problem was: why hasn’t this been solved yet?
I read multiple articles and watched many videos about how to use this tool - and was still confused! Your instructions were easy to understand and made the process simple.
Thanks,
Irene Hynes
You made some good points there. I did a search on the topic and found most people will agree with your blog..
ReplyDeleteAlso Visit this site to learn more about MuleSoft Online Training.
Your blog is really awesome thanks for sharing most valuable information with us, Mulesoft Online Training
ReplyDeleteNice information about test automation tools my sincere thanks for sharing post Please continue to share this post.
ReplyDeleteMULESOFT TRAINING
the blog is good and Interactive it is about Mulesoft Developer it is useful for students and Mulesoft Developers for more updates on Mulesoft mulesoft Online training hyderabad
ReplyDeleteReally Thanks For Posting Such a Useful Content. Really Thanks For Sharing Such an Informative Post.
ReplyDeleteMulesoft Certification Training
Mulesoft Training in Hyderabad
ReplyDeleteGreat article ...Thanks for your great information, the contents are quiet interesting.
ReplyDeleteMulesoft Online Training
this information is ussefull thank you
ReplyDeletemulesoft training in ammerpet
nice informations
ReplyDeletebest mulesoft training in ammerpet
thank you good information
ReplyDeletemulesoft training in hyderabad
its a great information
ReplyDeletebest mulesoft training in hyderabad
Nice blog.Thanks for sharing wonderful information with us.
ReplyDeleteMulesoft Online Training
Mulesoft Training in Hyderabad
https://mulesoft-technology.blogspot.com/2017/07/integration-with-microsoft-sharepoint.html?showComment=1575177594131#c6284138410807064724
ReplyDeleteThanks for sharing this information. I really Like Very Much.
ReplyDeletemulesoft online training in hyderabad
mulesoft esb online training
mulesoft online training and certification
ReplyDeleteThank you for sharing wonderful information with us to get some idea about it.
mulesoft training hyderabad
best mulesoft online training
best mulesoft training
mulesoft course online
mulesoft training and certification
mulesoft architecture certification
mulesoft course
mulesoft developer certification
I've encountered a problem with v5.4 (rebranded to Anypoint), where the inbound-endpoint has been deprecated and we're supposed to use http:listener
ReplyDeleteSalesforce Training in Chennai | Certification | Online Course | Salesforce Training in Bangalore | Certification | Online Course | Salesforce Training in Hyderabad | Certification | Online Course | Salesforce Training in Pune | Certification | Online Course | Salesforce Online Training | Salesforce Training
Thanks for sharing valuable information and very well explained. Keep posting.
ReplyDeleteworkday training
workday online course
Nice Blog!!!
ReplyDeleteMulesoft Training in Hyderabad
Mulesoft Online Training in India