Nav
You are viewing an older version of this section. Click here to navigate to the latest version.

Mule Examples

Mule provides a suite of tools to help you learn more about building applications in Studio and Mule Standalone. Walk through the Studio Configurations to learn the basics, or skip forward to learn from the Examples and Templates applications you can build using Mule ESB.

Studio Configurations

In order to demonstrate some of the key configuration activities in Mule Studio, review the videos and instructions in the Studio Basics Walkthrough section. Launch Studio and try mimicking the activities so as to gain familiarity and confidence in working with Studio.

Examples and Templates

Mule Examples offer insight into how you can use Mule to manage system connection and integration situations. Based on real-life business use cases, the examples demonstrate Mule’s powerful features and functionality, and suggest how you can take advantage of them.

Mule ESB 3.3 Community Edition (CE) and Mule ESB 3.3 Enterprise Edition (EE) include Templates of Mule example applications in the bundled download. These templates help you build a Mule application without having to start from scratch. You can use either the Using a Studio Template, Mule ESB’s graphical interface, or the Using a Standalone Example from your computer’s console, to quickly create your own applications in Mule ESB.

Template EE CE Description

Hello World

Illustrates a the configuration required to build a simple Web service.

Travel Agent

Exposes a SOAP-based Web service to reserve flights and hotels for specific timeframes.

Order Processing

Exposes a SOAP-based Web service that accepts order requests and processes each item in the order.

E-Store

Demonstrates how to use Mule to implement a traditional e-commerce tasks, such as browsing for products, adding to cart, checking out, authorizing payment, and placing vendor orders.

JDBC Transport

Demonstrates how to use a JDBC transport in a Mule application with Oracle and Sybase databases.

WebSphere MQ

Demonstrates how to use WMQ transport to send and receive transactional messages to WebSphere MQ.

Foreach

Illustrates how to use foreach to add information to each message in a collection.

Flight Reservation

Simulates a flight reservation system using several of new features in Mule 3.3, including new transformers, foreach, catch exception strategies, and the unified Mule expression language.

Scripting

Demonstrates how to invoke a JSR-223 script from Mule ESB; illustrates how to use custom transformers, how to route messages based on the type of message payload content, and how to use JVM environment variables.

Stock Quote

Demonstrates how to invoke an ASPX Web service from Mule, transform the result using XSLT, and deserialize the result to a StockQuote Java bean; uses REST and Web Services to invoke the service.

Security

Demonstrates different methods for adding WS-security to a Web service.

Bookstore

Demonstrates how to run Mule ESB as a web application inside a servlet container (using the Jetty connector), and how to use Mule with CXF Web service and the Servlet transport. (Template not available in Studio.)

Echo

Demonstrates how to add Logger and Echo to a flow to perform custom logging in your Mule application.

GPS Walker

Describes how to use AJAX to communicate from a Mule Service to a Web browser. (Template not available in Studio.)

Order Discounter

Processes XML orders, applies tiered discounts and sends Twitter status updates for orders.

Order Fulfillment

Processes XML orders, splits orders into items and routes them for fulfillment.

Mobile App

Demonstrates how to build an application for mobile.

Using a Studio Template

  1. If you haven’t already done so, visit www.mulesoft.org and download the free Community Edition of Mule ESB. Follow the instructions on the website to launch Mule Studio and select a workspace. (Alternatively, you can download and use the 30-day free trial of Mule ESB Enterprise Edition.)

  2. Click the File menu and select New > Mule Project.

  3. In the New Mule Project panel that appears, enter a Name for your new project and provide a brief Description, if you wish.

    proj_doc

  4. In the Server Runtime field, select the runtime version of Mule that you wish to use.

    • select Mule Server 3.3.0 CE if you downloaded the free Community Edition of Mule.

    • select Mule Server 3.3.0 EE if you downloaded the Enterprise Edition of Mule

      server_settings

  5. Click the box next to Create project based on an existing template.

  6. Click a line item to select the template you wish to use to build your project.

    avail_CE

    avail_EE

  7. Click Finish. Mule Studio creates and opens the new project, complete with pre-built and pre-configured flows.

  8. In the Package Explorer pane in Studio, right-click the project name, then select Run As > Mule Application. Studio runs the application and Mule is up and kicking!

  9. To stop the application from running, click the red Terminate button in Studio’s Console.

    terminate

Using a Standalone Example

  1. If you haven’t already done so, visit www.mulesoft.org and download the free Community Edition of Mule ESB. (Alternatively, you can download and use the 30-day free trial of Mule ESB Enterprise Edition.)

  2. Navigate to the folder that contains your copy of Mule ESB Standalone.

  3. Locate the Examples folder, then the folder for the example you wish to run.

  4. Copy the pre-built application archive (the .zip file) for the example.

  5. Paste the copy of the .zip file in the Mule applications folder, $MULE_HOME/apps. For example, to run the Flight Reservation example, copy mule-example-flight-reservation-3.3.0.zip and move the copy to the $MULE_HOME/examples folder.

    copy_archive

    Alternatively, you can build the example in a build tool such as Ant or Maven.

    1. Run ant or mvn in your Ant or Maven build tool, respectively.

    2. The build tool compiles the example classes, produces an application zip file and copies it to your $MULE_HOME/apps folder.

  6. Start Mule.

 Need more detail?
  1. Open a new command line.
    PC: Open the Console.
    Mac: Open the Terminal application (Applications > Utilities > Terminal).

  2. Access the directory and folder in which you pasted the zip file for your example (i.e. the application folder in Mule). For example, type cd /Users/aaron/Downloads/mule-standalone-3.3.0/

  3. Start Mule. For example, type ./bin/mule

  1. After it starts, Mule polls the apps and examples folders every 5 seconds; it picks up the applications you copied to the examples folder, then deploys it automatically. In the first command line, Mule notifies you that it has deployed the example application.

  2. To stop the application from running, hit CTRL-C.