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 > How to Grab Bits and Bytes From a Mule Exception Class

How to Grab Bits and Bytes From a Mule Exception Class

Most of us usually use #[exception] to log errors in our mule flows. Let's see how we can get most out of the exception class in our mule flows.

Ujjawal Kant user avatar by
Ujjawal Kant
·
Sep. 20, 16 · Integration Zone · Tutorial
Like (7)
Save
Tweet
6.56K Views

Join the DZone community and get the full member experience.

Join For Free

Most of us usually use #[exception] to log errors in our mule flows. Let's see how can we get most out of the exception class in our mule flows.

Let's take a scenario where we get a connection timeout exception over an http rest call.

Image title

Take a closer look at what gets logged using the below MELs when used in the Logger component present a Catch Exception Strategy.

1. Exception- #[exception] 

Exception- org.mule.api.MessagingException: Error sending HTTP request. 

2. Exception Class- #[exception.getClass()]

Exception Class- class org.mule.api.MessagingException

3. Exception Cause- #[exception.getCause()]

Exception Cause- java.net.ConnectException: Connect timeout

4. Exception Info- #[exception.getInfo()]    

Exception Info- {Payload Type=java.lang.String, Element=/sampleFlow1/processors/1 @   sample:sample.xml:16 (HTTP), Payload=, Element XML=<http:request config-           ref="HTTP_Request_Configuration" path="/Ok" method="GET" doc:name="HTTP">     </http:request>}

5. Exception Message- #[exception.getMessage()]    

Exception Message- Error sending HTTP request.

6. Exception Detailed Message- #[exception.getDetailedMessage()]

Exception Detailed Message- 
********************************************************************************
Message : Error sending HTTP request.
Payload : 
Payload Type : java.lang.String
Element : /sampleFlow1/processors/1 @ sample:sample.xml:16 (HTTP)
Element XML : <http:request config-ref="HTTP_Request_Configuration" path="/Ok" method="GET" doc:name="HTTP"></http:request>
--------------------------------------------------------------------------------
Root Exception stack trace:
java.net.ConnectException: Connect timeout
at org.glassfish.grizzly.connectionpool.SingleEndpointPool$ConnectCompletionHandler.cancelled(SingleEndpointPool.java:1284)
at org.glassfish.grizzly.impl.SafeFutureImpl.notifyCompletionHandlers(SafeFutureImpl.java:185)
at org.glassfish.grizzly.impl.SafeFutureImpl.done(SafeFutureImpl.java:277)
at org.glassfish.grizzly.impl.SafeFutureImpl$Sync.innerCancel(SafeFutureImpl.java:389)
at org.glassfish.grizzly.impl.SafeFutureImpl.cancel(SafeFutureImpl.java:247)
at org.glassfish.grizzly.connectionpool.SingleEndpointPool$ConnectTimeoutWorker.doWork(SingleEndpointPool.java:1352)
at org.glassfish.grizzly.connectionpool.SingleEndpointPool$ConnectTimeoutWorker.doWork(SingleEndpointPool.java:1344)
at org.glassfish.grizzly.utils.DelayedExecutor$DelayedRunnable.run(DelayedExecutor.java:158)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:745)

********************************************************************************

7. Exception Summary Message- #[exception.getSummaryMessage()]

Exception Summary Message- 
********************************************************************************
Message : Error sending HTTP request.
Element : /sampleFlow1/processors/1 @ sample:sample.xml:16 (HTTP)
--------------------------------------------------------------------------------
Exception stack is:
Error sending HTTP request. (org.mule.api.MessagingException)
org.glassfish.grizzly.connectionpool.SingleEndpointPool$ConnectCompletionHandler.cancelled(SingleEndpointPool.java:1284)
org.glassfish.grizzly.impl.SafeFutureImpl.notifyCompletionHandlers(SafeFutureImpl.java:185)
org.glassfish.grizzly.impl.SafeFutureImpl.done(SafeFutureImpl.java:277)
org.glassfish.grizzly.impl.SafeFutureImpl$Sync.innerCancel(SafeFutureImpl.java:389)
org.glassfish.grizzly.impl.SafeFutureImpl.cancel(SafeFutureImpl.java:247)
org.glassfish.grizzly.connectionpool.SingleEndpointPool$ConnectTimeoutWorker.doWork(SingleEndpointPool.java:1352)
org.glassfish.grizzly.connectionpool.SingleEndpointPool$ConnectTimeoutWorker.doWork(SingleEndpointPool.java:1344)
org.glassfish.grizzly.utils.DelayedExecutor$DelayedRunnable.run(DelayedExecutor.java:158)
org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
java.lang.Thread.run(Thread.java:745)

(set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

8. Exception Verbose Message- #[exception.getVerboseMessage()]

Exception Verbose Message- 
********************************************************************************
Message : Error sending HTTP request.
Payload : 
Payload Type : java.lang.String
Element : /sampleFlow1/processors/1 @ sample:sample.xml:16 (HTTP)
Element XML : <http:request config-ref="HTTP_Request_Configuration" path="/Ok" method="GET" doc:name="HTTP"></http:request>
--------------------------------------------------------------------------------
Root Exception stack trace:
java.net.ConnectException: Connect timeout
at org.glassfish.grizzly.connectionpool.SingleEndpointPool$ConnectCompletionHandler.cancelled(SingleEndpointPool.java:1284)
at org.glassfish.grizzly.impl.SafeFutureImpl.notifyCompletionHandlers(SafeFutureImpl.java:185)
at org.glassfish.grizzly.impl.SafeFutureImpl.done(SafeFutureImpl.java:277)
at org.glassfish.grizzly.impl.SafeFutureImpl$Sync.innerCancel(SafeFutureImpl.java:389)
at org.glassfish.grizzly.impl.SafeFutureImpl.cancel(SafeFutureImpl.java:247)
at org.glassfish.grizzly.connectionpool.SingleEndpointPool$ConnectTimeoutWorker.doWork(SingleEndpointPool.java:1352)
at org.glassfish.grizzly.connectionpool.SingleEndpointPool$ConnectTimeoutWorker.doWork(SingleEndpointPool.java:1344)
at org.glassfish.grizzly.utils.DelayedExecutor$DelayedRunnable.run(DelayedExecutor.java:158)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:745)

********************************************************************************

9. Exception Code- #[exception.getExceptionCode()]

Exception Code- -1

10. Exception Message Code- #[exception.getMessageCode()]

Exception Message Code- -1


11. Get Flow name that generated the Exception- 

#[exception.event.flowConstruct.name]    



You can actually try all of these in your MELs and get the most out of a mule exception class, so grab the best-suited one for your project. 

Thanks for reading! I hope this helps. Suggestions are welcomed in the comments.

Grab (software)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Caching Across Layers in Software Architecture
  • Monolith vs Microservices Architecture: To Split or Not to Split?
  • Major PostgreSQL Features You Should Know About
  • Blocking Ads on Your Network Using Raspberry Pi 3 + Fedora + Pi-hole

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