MULEESB's first development example-helloworld (ii)

Source: Internet
Author: User

In the previous blog post, we briefly introduced what an ESB is and taught you how to download and install studio.

Assume

Before you learn this tutorial, assume that you have downloaded, installed, and started AnyPoint Studio.

Create a new project
    1. Click File, select New>mule Project
    2. Open the New Mule Project Wizard, enter a name for our first project: My First Project , and then click Finish.
    3. Open a new blank project, here are the various views used to quickly build a mule project:
    4. Start designing our project and dragging an HTTP connector from the panel onto the canvas.
      Note: Studio automatically wraps the connector with a stream, saving you the steps of manually creating a flow.
    5. Drag a payload component into the canvas next to the HTTP connector, and also add it to the stream.
    6. Click the XML Configuration tab (at the bottom of the canvas) and we can see the application represented in XML.
      Studio has two ways of editing to make sure that the actions you add or change in the graphical interface are reflected in the XML configuration file. (Use the tabs below to view your application's graphics and XML configuration.) )

    7. Click the Messageflow tab to return to the graphical editor, and then click the Save icon to save the project.
Configuration Items

Now that you have built a basic application in studio, we need to configure each individual element below.

    1. Click the HTTP connector on the canvas to open its property editor (see).
      HTTP connectors allow mule applications to connect to any resource on the Web through an HTTP or HTTPS protocol.
      In order for the HTTP connector to function properly, basic information needs to be configured. The parameters that the connector must configure: path, and in the connector configuration, the name, host, and port that you want to configure. Other parameter configurations are optional.

      Path has been populated with default values, slashes / , we can use the default values in the connector configuration, or you can change the host to localhost.

      In a connector configuration, you can provide a reference to create another element.

    2. Click the plus sign next to the Green Connector configuration + to create a global element that is referenced by the connector. A global element is a separate element that encapsulates some reusable configuration properties that can be used by all other connectors.

    3. Opens a new window that contains several parameters for configuration. Leave the default values for all parameters, click OK to close the window and create a global element.

      Note: Return to the connector and populate the connector configuration with a reference to the element you just created. Notice that the connector's property editor and the red warning sign in the connector on the canvas are gone.

    4. On the canvas, click the Set Payload component to open its property editor (see).

    5. The Setpayload component sets the message payload to a fixed value, setting the value to a Hello World ! text string that you prefer.

    6. Click the XML configuration again to see our modified XML configuration (see code below). Click the Save icon to save your changes.

<?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"    xmlns:spring="Http://www.springframework.org/schema/beans" version="EE-3.6.2"    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.xsdhttp://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/ Current/mule.xsdhttp://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/ Mule-http.xsdhttp://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/ Mule-json.xsdhttp://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=" 0.0.0.0 " 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!" />    </Flow></Mule>
Deployment Project

AnyPoint Studio is bundled with its own embedded servers for deploying code when testing. Before you deploy an application on an embedded server in a production environment, you can see how it works and perform any debugging activities, such as a local server or Cloudhub.

    1. Right-click the project name in the Package explorer and select Run as > Mule application.
    2. Launch the application on the embedded server and display its behavior in the console. When finished, the console message reads: Start applying "My_first_project"
Calling the project
    1. Open your browser
    2. Enter the URL of the calling application (this address is the default configuration of the HTTP connector):
      http://localhost:8081
    3. The application accepts the request through the HTTP endpoint, then sets the load, sets the payload "Hello world!" and finally, you can see in your browser that the HTTP connector returns this payload response.
    4. Stop the application using the Terminate icon in the console:

Original link: https://docs.mulesoft.com/mule-fundamentals/v/3.7/build-a-hello-world-application
In the next blog post, we translate Mule's introductory tutorials.

MULEESB's first development example-helloworld (ii)

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.