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
- Click File, select New>mule Project
- Open the New Mule Project Wizard, enter a name for our first project:
My First Project
, and then click Finish.
- Open a new blank project, here are the various views used to quickly build a mule project:
- 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.
- Drag a payload component into the canvas next to the HTTP connector, and also add it to the stream.
- 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.) )
- 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.
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.
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.
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.
On the canvas, click the Set Payload component to open its property editor (see).
The Setpayload component sets the message payload to a fixed value, setting the value to a Hello World !
text string that you prefer.
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.
- Right-click the project name in the Package explorer and select Run as > Mule application.
- 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
- Open your browser
- Enter the URL of the calling application (this address is the default configuration of the HTTP connector):
http://localhost:8081
- 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.
- 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)