Hi All,
i am new to camel and just playing around with this.i was trying to
understand how error handling is working around.
i have the following case
i am picking csv from a location and using build in parsing converting it to
java object and in my Bean class i am throwing "IllegalClassFormatException"
to check how it can be handled
here is my route configuration and other stuff
context.addRoutes(new RouteBuilder() {
public void configure() {
onException(IllegalClassFormatException.class).handled(true).bean(new
MyBean(), "validationFailed").
to("file:data/failed").useOriginalMessage().stop();
from("file:data?fileName=myfile.csv").unmarshal().csv()
.bean(new
Bean(),"csvHandler").to("file:data/output?fileName=xmlfile.xml");
}
});
context.start();
Thread.sleep(10000);
context.stop();
MyBean class has following 2 methods
public String csvHandler(@Body List<List<String>> data) throws
IllegalClassFormatException{
throw new IllegalClassFormatException();
}
@SuppressWarnings("unchecked")
public Object validationFailed(@Headers Map in, @Body String payload,
@OutHeaders Map out) {
return "Order ERROR";
}
i can see that moment my Bean class being calle din the route its throwing
IllegalClassFormatException and i have configured onException() as described
in the code above
in the log entries i can even saw that "Order ERROR" is being set in the
message header but i am clueless how i can retrieve it in my class to show
end user this message
like in my main method i am using
route.callRoute();
where route is the class reference where i am adding route,configuring it
and starting camel context as well stopping it.
i am just confused how one can show end user what exactly happened (say in
my case csv was invalid)
thanks in advance
Aum
--
View this message in context:
http://camel.465427.n5.nabble.com/camel-Error-Handling-tp4681829p4681829.html
Sent from the Camel - Users mailing list archive at Nabble.com.