Build a Hello World Mule Application

Mule Runtime Engine versions 3.5, 3.6, and 3.7 reached End of Life on or before January 25, 2020. For more information, contact your Customer Success Manager to determine how you can migrate to the latest Mule version.

It’s time to roll up your sleeves and build your first Mule application in Anypoint Studio!

The objective of this tutorial is get something built and running fast, so this document doesn’t spend much time explaining components. This tutorial shows you how to create a simple application in Studio, deploy it to Studio’s embedded server, and then interact with the application through a Web browser.


This tutorial assumes that you have installed, and launched Anypoint Studio, and that you’ve read through the Anypoint Studio Essentials.

Creating a New Project

  1. In Anypoint Studio, click File then select New > Mule Project.

  2. Studio opens the New Mule Project wizard. In the Project Name field, enter the value My First Project, then click Finish.

  3. Studio opens a new blank project. The following quick reference explains the different views you use to build a Mule project:

  4. Drag and drop an HTTP Connector from the palette onto the canvas. Studio wraps the connector with a flow.

  5. Add a Set Payload Component to your flow by dragging it next to the HTTP connector.

  6. Use Message Flow and Configuration XML tabs below the canvas for alternating between visual and XML editing. Click the Configuration XML tab to see your application represented in XML.

  7. Click the Message Flow tab to return to the graphical editor.

  8. Click the Save icon to save your project.

Configuring the Project

Now that you’ve modeled a basic application in Studio, you can follow the steps in this section to configure each individual element. The first element to configure is the HTTP Connector. The HTTP Connector allows your Mule application to connect to Web resources through the HTTP or HTTPS protocol. First, you set required HTTP Connector properties:

  • Path

  • Connector Configuration

  • Name

  • Host

  • Port

You also create a Global Element for the HTTP Connector to reference. The Global Element encapsulates some reusable configuration properties. Multiple connectors can reuse the Global Element.

To configure the project:

  1. Click the HTTP Connector on the canvas to open its properties editor.

  2. Path is already populated by the default value, slash /. For this example, accept the default values in Connector Configuration, or change Host to localhost.

  3. Click the green plus sign (+) next to Connector Configuration to create a new Global Element.

  4. In Global Element Properties, accept the default values for all fields, and click OK to close the window.


    The Connector Configuration field is now populated with a reference to the element you just created. The red warning marks disappear from the properties editor and the representation for the connector on the canvas.

  5. Click the Set Payload Component on the canvas to open its properties editor in the console.

    The Set Payload Component simply sets the message payload to a value you define.

  6. Set the Value field to Hello World! for example.

  7. Once again, click the Configuration XML to view your changes in the XML configuration tab:

    <?xml version="1.0" encoding="UTF-8"?>
    <mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:json="http://www.mulesoft.org/schema/mule/json" 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"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
    http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
    http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
    http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
    http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
        <http:listener-config name="HTTP_Listener_Configuration" host="" port="8081" doc:name="HTTP Listener Configuration"/>
       <flow name="my_first_projectFlow">
            <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
            <set-payload doc:name="Set Payload" value="Hello World!"/>
  8. Click the Save icon to save your changes.

Deploying the Project

Anypoint Studio embeds a server that you use for testing deployments as you code. You can deploy your application on the embedded server to see it working and perform any debugging activities before deploying to a production environment, such as an on-premises server or CloudHub.

  1. In the Package Explorer, right-click the project name, then select Run As > Mule Application.

  2. Studio launches the application on the embedded server, displaying its actions in the console. When complete, the console message reads: Started app 'my_first_project'


Interacting with the Project

  1. Open a Web browser.

  2. Navigate to the URL of your application, the default set by HTTP Connector properties:

  3. The application accepts the request via its HTTP endpoint, then the set payload component sets the payload to "Hello World!", and finally the HTTP connector returns this payload to your browser.

  4. In Studio, stop the application from running using the Terminate icon in the console:


See Also

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub
Submit your feedback!
Share your thoughts to help us build the best documentation experience for you!
Take our latest survey!