DZone
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
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Coding
  3. Java
  4. Mule Dismantle, Mule example with Logger

Mule Dismantle, Mule example with Logger

Kasi Ramanathan user avatar by
Kasi Ramanathan
·
Feb. 04, 15 · Interview
Like (1)
Save
Tweet
Share
2.96K 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

  • Using JSON Web Encryption (JWE)
  • Remote Debugging Dangers and Pitfalls
  • Kotlin Is More Fun Than Java And This Is a Big Deal
  • Load Balancing Pattern

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • 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: