Hi

Just route to a bean in the <onException> section.

<onException>
   ..
  <to uri="bean:myBean"/>
</onException>

And the spring bean
<bean id="myBean" class=...">

And the bean signature uses bean parameter binding with Camel

For example the 1st parameter is the message body, the 2nd the caused
exception etc.
public void doSomething(Object body, Exception cause) {

}




On Wed, Nov 23, 2011 at 7:57 AM, majiedahamed
<majied.ban...@cognizant.com> wrote:
> Hi,
>
> I have the following exception handling in one of the route,Camel is
> catching the exception given in the list into the log file.All i want is to
> catch the same exception in java code to handle with some logic.I wanted to
> format a response message with the faliure flag and exception description to
> the failed messages in the route using a spring bean.Please help me on this
> issue
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> <onException useOriginalMessage="true">
>
> <exception>org.apache.camel.processor.validation.SchemaValidationException</exception>
> <exception>org.xml.sax.SAXParseException</exception>
> <exception>org.apache.camel.ValidationException</exception>
> <exception>java.io.IOException</exception>
> <exception>org.springframework.mail.MailSendException</exception>
> <exception>javax.xml.xpath.XPathExpressionException</exception>
> <exception>org.apache.camel.ResolveEndpointFailedException</exception>
> <exception>java.text.ParseException</exception>
> <exception>java.lang.NullPointerException</exception>
> <exception>javax.xml.transform.TransformerException</exception>
>
>
>        <exception>java.lang.Exception</exception>
>
> <redeliveryPolicy maximumRedeliveries="0" />
> <handled>
> <constant>true</constant>
> </handled>
>
>
> <to
> uri="log:xml?level=INFO&amp;showException=true&amp;showCaughtException=true&amp;showStackTrace=true"
> />
>
> <to uri="file:{{retry_loc}}" />
>
> </onException>
>
> +++++++++++++++++++++++++++++++++++++++++++++
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Catch-camel-exception-in-java-code-tp5015714p5015714.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Reply via email to