Well yes, i want that fs there is some exception in my route execution like for e.g my csv file isinvalid and in my bean class i am throwing an exception to indicate that csv is not valid
in this case i am handling this exception in my onException() and even in MyBean class i am setting a message that csv was not valid but camelContext.startRoute() method have void return type so i am a bit confused how i will able to get status what happened while executing the route so that message can be passed on to the end user i hope i am able to clear it this time On Wed, Aug 10, 2011 at 6:06 PM, Claus Ibsen <claus.ib...@gmail.com> wrote: > On Tue, Aug 9, 2011 at 2:16 PM, aum.struts <aum.str...@gmail.com> wrote: > > 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) > > > > Its a bit unclear what you want to do? Do you want the callRoute() > method to return some status of how it went? OK or in case of an > failure, some kind of exception message or what? > > In all cases its just java code, so you can just add some state to the > route class, and use that to compute a response to return from the > callRoute method. > > > > > 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. > > > > > > -- > 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/ >