VOOZH about

URL: https://dzone.com/articles/mule-sample-application

⇱ Creating a Mule ESB Sample Hello World Application


Related

  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Creating a Mule ESB Sample Hello World Application

Creating a Mule ESB Sample Hello World Application

Mule is a lightweight, open source integration framework. In this tutorial, learn the requirements and steps for creating a sample Mule application.

By Updated Jan. 14, 21 · Tutorial
Likes
Comment
Save
91.0K Views

Join the DZone community and get the full member experience.

Join For Free

Mule ESB is an integration technology that can connect different applications. Mule is an open-source integration framework consisting of different Connectors that can easily integrate our applications.

Mule is a lightweight integration framework. Mule ESB includes powerful capabilities including REST, SOAP, JMS, Salesforce, Cloudhub, RAML, Http, Datasource, Dataweave, Java, and MongoDB.

MuleSoft Anypoint Studio is a user-friendly IDE where we can easily drag Connectors from the Mule Palette.

In this article, I am going to show you how to create a Mule ESB Sample Application. For this, we need the below requirements.

1. Java 8 (JDK 1.8)

2. Anypoint Studio

3. Postman

Mule ESB Sample Application

XML




x
15


1
<?xml version="1.0" encoding="UTF-8"?>
2

 
3
<mule 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"
4
xmlns:spring="http://www.springframework.org/schema/beans" 
5
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
7
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
8
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
9

 
10
  <http:listener-config name="HTTP_Listener_Configuration1" host="0.0.0.0" port="8081" basePath="/sample" doc:name="HTTP Listener Configuration"/>
11
    <flow name="sample-appFlow">
12
        <http:listener config-ref="HTTP_Listener_Configuration1" path="/{parmname}" allowedMethods="GET" doc:name="HTTP"/>
13
        <set-payload value="#[message.inboundProperties.'http.uri.params'.parmname]" doc:name="Set Payload"/>
14
    </flow>
15
</mule>



Follow the below steps or copy the above code into Mule Configuration XML (src/main/app/sample-app.xml).

Step 1: Open Anypoint Studio and Create a new project using File->New ->Mule Project.

Step 2: Type a Project Name like "sample-app" and press the Finish button.

Step 3: Drag an HTTP Connector from Mule Palette.

Step 4: Click on the HTTP Connector and you can find HTTP Attributes in the below screen. We need to configure some details of the HTTP Connector.

Step 5: Configure port "8081" and the Base path as "/sample" & press the OK button.

Step 6: Set the path as "/{paramname}" and Allowed Methods to "GET."

Step 7: Drag a Set Payload from Mule Palette.

Step 8: Click on Set Payload and set the value.  #[message.inboundProperties.'http.uri.params'.parmname] 

Step 9: To run this application, right click on Mule Flow and select "Run Project sample-app."

Step 10: You can see some logs in the console screen; the status is showing that the application was deployed.

Step 11: Go to Postman:

                Select Method: "GET"

                URL: http://localhost:8081/sample/

                Param value: Helloworld

                Example: http://localhost:8081/sample/Helloworld

Step 12: To stop the application, go to Mule Flow, right click and select "Stop Project sample-app."

Enterprise service bus application

Opinions expressed by DZone contributors are their own.

Related

  • A Spring Boot App With Half the Startup Time
  • Key Takeaways From Integrating a RAG Application With LangSmith
  • Improving Java Application Reliability with Dynatrace AI Engine
  • Enabling Single-Sign-On in SaaS Application

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

Let's be friends: