camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen" <claus.ib...@gmail.com>
Subject Re: not getting exception from exchange
Date Wed, 10 Dec 2008 10:22:57 GMT
On Wed, Dec 10, 2008 at 1:12 AM, ychawla <premiergeneration@yahoo.com> wrote:
>
> Hello All,
> Here is a simple route that will catch an exception:
>
>      <from uri="file:/dropOff"/>
>      <convertBodyTo type="java.lang.String"/>
>      <to uri="bean:authorizationBean"/>
>         <onException>
>                  <exception>java.lang.Exception</exception>
>                  <redeliveryPolicy maximumRedeliveries="0"/>
>                  <handled>
>                    <constant>true</constant>
>                  </handled>
>                        <bean ref="errorResponseBean" method="createErrorResponse"/>
>                        <convertBodyTo type="java.lang.String"/>
>                        <to uri="file:/error?append=false"/>
>              </onException>
>          <to uri="activemq:SSAF.WorkflowProcessingQueue"/>
>
> In the error response bean, I try to get the exception from the Exchange
> with no luck:
> exchange.isFailed();  //this is false
> exchange.getException(); //this is null
I think that is because you have stated it as handled=true, so you get
the Exchange without the exception, so the routing that continues
don't think there is an error and thus will break and send it to the
error handler.


>
> However, I can get it from the message.  While debugging, I saw it as a
> property:
> Exception ssafException = (Exception)
> exchange.getProperty("CamelCauseException");
Yeah I think it's stored there as a kind of fallback to get it. We
might wanna expose this more nicely.


>
> Am I doing something wrong here?
>
No.

> Also, if I go the reliable messaging route and send the error message to an
> error queue first and then to a bean, I am unable to get the exception using
> the property CamelCauseException.  I think this is because exceptions can be
> sent as part of the activemq message.  I recall reading a feature for this
> might be available in 2.0.
Yeah we have two related tickets. Please comment and use to voting
system to help us prioritize tickets.
On ticket to force setting what kind of JMS message type to use
(Object, Text etc.)
And the other is to mirror the transferExchange we have in camel-mina.
This requires camel on both sides. And is what you are looking for.


>
> What I would like to do is have any errors that are thrown by any route sent
> to an error processing queue and then have a bean that handles all of them.
> The bean will go into the Exchange and get the exception.  Depending on the
> type of exception, it will produce a different custom xml error to send back
> to the client.  I can do the last part, but am having problems getting that
> exception.
You can create you own Object that is not an exchange object and wrap
the information you want to send/retrieve over JMS.
Take a look at the camel-mina source code.

If you get a good solution, or a good start. Then remember we love
contributions.


/Claus

>
> Cheers,
> Yogesh
> --
> View this message in context: http://www.nabble.com/not-getting-exception-from-exchange-tp20926633s22882p20926633.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>

Mime
View raw message