ESB
1.下載
http://www.mulesoft.org/documentation/display/MULE2INTRO/Home
下載Mule ESB 2.2.1 Full Dist.
2.zip 文件
3.安裝所需要的環境
http://www.mulesoft.org/documentation/display/MULE2INTRO/Installing+Mule
java1.5+
Mule Build Tool有三種方式
Ant/Maven/Mule IDE
下面以Maven 為例進行操作
4.設置環境變量
比如
Linux/UNIX
export JAVA_HOME=/opt/java/jdk
export MAVEN_HOME=/opt/apache/maven-2.0.9
export MAVEN_OPTS='-Xmx512m -XX:MaxPermSize=256m'
export MULE_HOME=/opt/mule
export PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin:$MULE_HOME/bin
Windows
set JAVA_HOME=C:\Program Files\Java\jdk
set MAVEN_HOME=C:\Apache\maven-2.0.9
set MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=256m
set MULE_HOME=C:\Mule
set PATH=%PATH%;%JAVA_HOME%\bin;%MAVEN_HOME%\bin;%MULE_HOME%\bin
Note: If you will run Mule as a Windows service, you must create system environment variables instead of user environment variables.
創建一個Maven repository 目錄,比如c:\.m2\repository 在windows系統上,如果windows 不讓創建.m2文件夾,請用mkdir目錄創建
打開Maven conf 目錄,比如c:\apache-maven-2.0.9\conf;打開setting.xml 文件,查找localRepository
將注釋去除或者添加一段
<localRepository>c:/.m2/repository</localRepository>
5.run Hello Word
進入windows cmd 命令行,分別查看ant/maven是否正常
在%MULE_HOME%\lib\user 中查看是否存在mule-example-hello.jar
如果不存在 那么我們需要ant 或者 mvn 來build jar
我對mvn不是很熟悉,就用ant,在MULE_HOME%\examples下可以看到hello的例子
下面有build.xml 和pom.xml
查看build.xml 會發現,執行ant setup就能build hello project
在下來就要運行mule,hello文件夾下面的readme有描述
------------------
Linux / Unix
------------
mule -config file:conf/hello-config.xml
mule -config file:conf/hello-http-config.xml
or
export MULE_LIB=./conf
mule -config hello-config.xml
mule -config hello-http-config.xml
Windows
-------
mule.bat -config file:conf/hello-config.xml
mule.bat -config file:conf/hello-http-config.xml
or
SET MULE_LIB=.\conf
mule.bat -config hello-config.xml
mule.bat -config hello-http-config.xml
如果運行 http config那么通過
http://localhost:8888/?name=Ross 可訪問
--------------------------------------------
更方便的是例子下面提供了hello.bat 直接運行該bat 并輸入1或者2為參數就能啟動hello mule
(需要提醒的是,第一次啟動mule會有一大堆許可文件要你看,你輸入任何鍵回車后多次過后你就能發現mule啟動成功了)
在conf下有hello-config.xml/hello-http-config.xml
hello-config.xml他們在console端,通過system.in輸入message,然后在system.out輸出
hello-http-config.xml 表示在瀏覽器中輸入http://localhost:8888/?name=Ross 那么web頁面會現在動態的name
6最簡單構建Mule project
你可以通過安裝Eclipse Mule IDE
http://www.mulesoft.org/documentation/display/MULE2INTRO/Quick+Start
或者Setting Up Eclipse for Use with Maven
http://www.mulesoft.org/documentation/display/MULE2INTRO/Setting+Up+Eclipse+for+Use+with+Maven