camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ramon Buckland" <ra...@thebuckland.com>
Subject Attempting to capture Exception from properties using <el>
Date Sat, 06 Dec 2008 11:47:19 GMT
Hi All,

I have come across something unusual which I am hoping someone can shed some
light on.

I am currently testing failure paths of some routes, and as part of the
"reporting" of a failure, I need to send an email.

I have a catch all onException config in the route ..

      <onException>
        <exception>java.lang.Exception</exception>
        <redeliveryPolicy maximumRedeliveries="0"/>
        <multicast>
          <to uri="direct:exceptionEmail"/>
          <transform><constant>FAIL</constant></transform>
        </multicast>
      </onException>

Which is designed to perform two tasks,
   (a) forward the "exception" details out to an email
   (b) respond with FAIL back to the "caller"

(b) is working nicely.

For (a), the direct:exceptionEmail looks as follows

    <route>
      <from uri="direct:exceptionEmail"/>
        <pipeline>
          <!-- log to help with debug -->
          <to
uri="log:internal.company.ExceptionFailure?level=INFO&amp;showAll=true"/>
          <setHeader headerName="subject">FAIL - System Status - An
Exception was caught</setHeader>
          <setBody>
              <el>
              An unexpected error occured. Please review the logs for more
details.
              ${in.properties['CamelCauseException']}
              </el>
          </setBody>
          <to uri="smtp://smtpserver?to=ramon@myemail.com
&amp;from=system@company.internal"/>
        </pipeline>
    </route>

The problem I am seeing is that the <el> attempting to capture the exception
details is saying there is no "properties"

DEBUG Pipeline                       - Message exchange has failed so
breaking out of pipeline: Exchange[Message: execute-job-1] exception:
javax.el.PropertyNotFoundException: The class
'org.apache.camel.impl.DefaultMessage' does not have the property
'properties'. fault: null

This is well and good, (I can see via the source that, indeed,
org.apache.camel.impl.DefaultMessage does not have a getProperties .. etc)
however, the log which is running before, shows the message does actually
have Properties, and the property I am after (CamelCauseException).

INFO  ExceptionFailure               -
Exchange[Id:ID-itasca/50862-1228562841594/0-1,
Properties:{org.apache.camel.processor.DeadLetterChannel.FAILURE_HANDLED=internal.company.MyException:
MyException details, org.apache.camel.bean.BeanHolder=bean: aBean,
CamelCauseException=internal.company.MyException: MyException details},
Headers:{org.apache.camel.RedeliveryCounter=0 ... --SNIP Headers-- },
BodyType:String, Body:execute-job-1, Out: null]

Where is the disconnect occuring ? Can Juel (<el>) get to the Properties of
a message ?

I can see that Ognl (http://activemq.apache.org/camel/ognl.html) has the
properties exposed (so I might just switch) but if there is a bug, or some
impl to do, let me know and I can dive in to this one.

regards
Ramon

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message