camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen" ...@silverbullet.dk>
Subject RE: Error Handler and OutHeaders
Date Tue, 14 Oct 2008 12:13:39 GMT
Hi

The ticket for the annotation is: CAMEL-985

Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: Claus Ibsen [mailto:ci@silverbullet.dk] 
Sent: 14. oktober 2008 14:10
To: camel-user@activemq.apache.org
Subject: RE: Error Handler and OutHeaders

Hi

Ah I see. This is interesting.
You can get the caused exception using Exchange.getException()

So your method transformFailed needs the Exchange parameter

Public void transformFailed(Exchange exchange, @Body String payload, ...) {
  Throwable caused = exchange.getException();
}

We currently don't have an @ annotation to bean bind the caused exception. But we will add
it in the future. So you can do something like this:

Public void transformFailed(@Exception Exception caused, @Body String payload, ...) {



Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: borgel [mailto:borge.lotre@gmail.com] 
Sent: 14. oktober 2008 13:51
To: camel-user@activemq.apache.org
Subject: RE: Error Handler and OutHeaders


I see. 
What I was planning to do was to handle the exception by storing information
about it in the database. Is it possible to use the Exception itself in the
route?
Of course I can handle this in the code (catch the Exception and store all I
need), but I thought it was better to just throw the Exception and then
handle it in the route.


Claus Ibsen wrote:
> 
> Hi
> 
> Yeah the sample is identical. But when the exchange fails, and onException
> is taking over, then it's the *original* exchange (= copy, aka snapshot)
> that is used, just before the node that fails.
> 
> So its kinda like this
> 
>  		from(fromRoute)
> TAKE SNAPSHOT (A)
>  		.beanRef("listTransformer", " fromStringToFundList initId") 
> TAKE SNAPSHOT (B)
>             .to("bean:fundListDao?methodName=save");			
> 
> So when the beanRef fails and onException is kicked in, then the exchange
> that is used there is from SNAPSHOT A. It need to do a SNAPSHOT when it
> does retries.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Error-Handler-and-OutHeaders-tp19970966s22882p19971930.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message