Hi
Id is null because the exchange that is caught by onException is a snapshot of
the exchange just before your bean listTransformer is invoked.
Any changes to the exchange that happens in listTransformer is not
effective/visible for the error handler.
You can use 2 bean calls to let the id be visible
from(fromRoute)
.beanRef("listTransformer", "initId")
.beanRef("listTransformer", "fromStringToFundList")
.to("bean:fundListDao?methodName=save");
For instance a initId() method that is simple and just set the id.
Then if there is a failure in the 2nd bean then the snapshot is from just
before the 2nd bean call.
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:[EMAIL PROTECTED]
Sent: 14. oktober 2008 12:38
To: [email protected]
Subject: Error Handler and OutHeaders
I have set up a route with an error handler like this:
@Override
public void configure() throws Exception
{
onException(TransformException.class)
.handled(true)
.beanRef("listTransformer", "transformFailed")
.to("bean:errorDao");
from(fromRoute)
.beanRef("listTransformer", "fromStringToFundList")
.to("bean:fundListDao?methodName=save");
}
in the listTransformer I add an id value to the map:
public List<Fund> fromStringToFundList(@Headers Map in,
@org.apache.camel.Body String payload, @OutHeaders Map out)
{
Header header = getHeader(payload);
id = header.getId();
out.put("headerId", id);
logger.info("Id in transformer: " + id);
List<Fund> funds = getFunds(payload)
return funds
}
When an error occurs in getFunds the errorHandler kicks in and calls
transformFailed:
public Object transformFailed(@Headers Map in, @org.apache.camel.Body String
payload, @OutHeaders Map out)
{
logger.info("Id in transformFailed: " + in.get("headerId"));
return "ERROR";
}
This will produce the following output:
Id in transformer: 586
Id in transformFailed: null
Why is id in transformFailed null?
--
View this message in context:
http://www.nabble.com/Error-Handler-and-OutHeaders-tp19970966s22882p19970966.html
Sent from the Camel - Users mailing list archive at Nabble.com.