DZone
Integration Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Integration Zone > Mule Dismantle, Mule example with Logger

Mule Dismantle, Mule example with Logger

Kasi Ramanathan user avatar by
Kasi Ramanathan
·
Feb. 04, 15 · Integration Zone · Interview
Like (1)
Save
Tweet
2.81K Views

Join the DZone community and get the full member experience.

Join For Free

Logger and message

Create a mule flow, add an http end point with the default host and port name.

Host: localhost

Port: 8081

Note: For practicing always use an http end point as it is easy to create and test.

Then add a logger component with the message value as #[payload], followed by one more logger component with message value as #[message].

The flow will look like this:

And the xml configuration looks as below:

<?xml version="1.0" encoding="UTF-8"?>
<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"
   xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.5.0"
   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.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">
    <flow name="dismantlemuleFlow1" doc:name="dismantlemuleFlow1">
      <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
      <logger message="#[payload]" level="INFO" doc:name="Logger"/>
      <logger message="#[message]" level="INFO" doc:name="Logger"/>   
    </flow>
</mule>

Run the application and hit the url with http://localhost:8081/testdata and you will get the following output in the console.

I

NFO  2015-01-28 08:30:10,677 [[dismantlemule].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: /testdata

INFO  2015-01-28 08:30:10,692 [[dismantlemule].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor:

org.mule.DefaultMuleMessage

{

  id=c5cde650-a699-11e4-8792-a0d3c169f60f

  payload=java.lang.String

  correlationId=<not set>

  correlationGroup=-1

  correlationSeq=-1

  encoding=UTF-8

  exceptionPayload=<not set>

Message properties:

  INVOCATION scoped properties:

  INBOUND scoped properties:

  Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

  Accept-Encoding=gzip, deflate

  Accept-Language=en-US,en;q=0.5

  Connection=true

  Host=localhost:8081

  Keep-Alive=true

  MULE_ORIGINATING_ENDPOINT=endpoint.http.localhost.8081

  MULE_REMOTE_CLIENT_ADDRESS=/127.0.0.1:50584

  User-Agent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0

  http.context.path=/

  http.context.uri=http://localhost:8081

  http.headers={Keep-Alive=true, Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8, Connection=true, User-Agent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0, Host=localhost:8081, Accept-Encoding=gzip, deflate, Accept-Language=en-US,en;q=0.5}

  http.method=GET

  http.query.params={}

  http.query.string=

  http.relative.path=testdata

  http.request=/testdata

  http.request.path=/testdata

  http.version=HTTP/1.1

  OUTBOUND scoped properties:

  MULE_ENCODING=UTF-8

  SESSION scoped properties:

}

The first line Is the output of the #[payload] mule expression, which as the name suggest prints the payload.

INFO  2015-01-28 08:30:10,677 [[dismantlemule].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: /testdata

And rest are the output of #[message] which gives the complete information of the message.

Note: Logging output of the payload will be very useful in debugging, like system.out.println in java. As it gives the clear information of how the payload looks at different stage of the flow.


Host (Unix) Payload (computing) Flow (web browser) application Console (video game CLI) Java (programming language) Testing Clear (Unix)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Which JVM Version Is the Fastest?
  • 12 Kick-Ass Software Prototyping and Mockup Tools
  • How to Properly Format SQL Code
  • Datafaker: An Alternative to Using Production Data

Comments

Integration Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo