Mule installation, configuration, and running of simple examples

Source: Internet
Author: User
Tags time in milliseconds

Recently, I started to access ESB. In the field of Open-Source ESB, the most widely used is Mule. However, unfortunately, there is not much useful information about ESB on the Internet, so I will write down my learning, usage, and familiarity here. If there are any errors, you are welcome to point out and discuss them.

 

1. Download, install and configure

1.1 download Mule-Http://www.mulesoft.org/

1.2 download Mule IDEHttp://www.mulesoft.org/documentation/display/MULEIDE/Mule+IDE+2.0+Installation+Guide

Here, Mule IDE is an Eclipse plug-in. Its installation and configuration are described in detail on the official site. I am using

Eclipse: MyEclipse 6.5

Mule: mule-2.1.2

Operating System: Windows XP

Note:The JDK in Eclipse should be consistent with the JDK installed in the system.

 

2. Running example

2.1 run directly

There are several examples in the % Mule_Home % \ examples directory that can be run directly, such as running echo and directly running echo in the echo directory. bat. Three modes are provided: Command Line and Axis and Cxf-based services. The following two figures show the command line running and the running based on the Axis service. If the latter is used, enter the following address in the browser: http: // localhost: 65081/services/EchoUMO? Method = echo

 

2.2 run in Development Environment

2.2.1 create a Mule Project

Enter the project name, select Add sample project content, select Echo Example from the drop-down list, and Finish.

 

2.2.2 run

After creating a project, you can view the project structure, right-click any xml configuration file in the conf directory, and Run As-> Mule Server to Run the file.

 

3. Develop the first Mule project -- Hello World

3.1 create a project-Create a Java Project

 

3.2 Add the required JAR package

Add a lib folder and copy all the JAR packages in the following directory to the lib folder.

-- % Mule_Home % \ lib \ boot

-- % Mule_Home % \ lib \ mule

-- % Mule_Home % \ lib \ opt

And add these JAR packages to the project's classpath.

 

3.3 compile a Java File

3.3.1 create an interface

3.3.2 create an implementation class

/***********************************************************************  * <p>Project Name: test</p>  * <p>File Name: com.thu.afa.mule.demo.HelloImpl.java</p>  * <p>Copyright: Copyright (c) 2010</p>  * <p>Company: <a href="http://afa.thu.com">http://afa.thu.com</a></p>  ***********************************************************************/ package com.thu.afa.mule.demo;  /**  * <p>Class Name: HelloImpl</p>  * <p>Description: </p>  * @author Afa  * @date Jun 26, 2010  * @version 1.0  */ public class HelloImpl implements Hello { /* (non-Javadoc)  * <p>Title: </p>  * <p>Method Name: hello</p>  * <p>Description: </p>  * @author: Afa  * @date: Jun 26, 2010  * @see com.thu.afa.mule.demo.Hello#hello(java.lang.String)  *  * @param name  * @return  */ public String hello(String name) { return name; }  } 

 

3.4 compile a configuration file

Create the conf folder under the project directory and create the file: hello-config.xml. Of course, you can also copy a configuration file from the mule example here and make appropriate modifications. The configuration in this example is as follows:

<?xml version="1.0" encoding="UTF-8"?> <mule xmlns="http://www.mulesource.org/schema/mule/core/2.1"        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"        xmlns:spring="http://www.springframework.org/schema/beans"        xmlns:stdio="http://www.mulesource.org/schema/mule/stdio/2.1"        xmlns:vm="http://www.mulesource.org/schema/mule/vm/2.1"        xsi:schemaLocation="                http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd                http://www.mulesource.org/schema/mule/core/2.1 http://www.mulesource.org/schema/mule/core/2.1/mule.xsd                http://www.mulesource.org/schema/mule/stdio/2.1 http://www.mulesource.org/schema/mule/stdio/2.1/mule-stdio.xsd                http://www.mulesource.org/schema/mule/vm/2.1 http://www.mulesource.org/schema/mule/vm/2.1/mule-vm.xsd">          <!--         The system stream connector is used to send and receive information via the         System.in and System.out. Note this connector is only really useful for testing         purposes.         promptMessage - is what is written to the console         messageDelayTime - is the time in milliseconds before the user is prompted again.         These properties are set as bean properties on the connector.     -->     <stdio:connector name="SystemStreamConnector"         promptMessage="Please enter yout name: "         messageDelayTime="1000"/>     <!--         The Mule model initialises and manages your UMO components     -->     <model name="HelloSample">         <!--             A Mule service defines all the necessary information about how your components will             interact with the framework, other components in the system and external sources.             Please refer to the Configuration Guide for a full description of all the parameters.         -->         <service name="HelloUMO">             <inbound>                 <stdio:inbound-endpoint system="IN" />             </inbound>                          <component class="com.thu.afa.mule.demo.HelloImpl"/>              <outbound>                 <pass-through-router>                 <stdio:outbound-endpoint system="OUT" />                 </pass-through-router>             </outbound>         </service>          </model> </mule> 

3.5 run

Right-click the hello-config.xml and Run As-> Mule Server to Run. The running result is As follows:

 

4. Summary

I have been reading Mule's official documents and examples recently. However, since I am a beginner, I have little theoretical knowledge. If there are any mistakes, please note, you are also welcome to discuss it together.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.