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: camel Error Handling
Date Thu, 11 Aug 2011 14:57:28 GMT
Hi

In the bean that handles the error handling, I think that is
CSVConverterBean in the method validationFailed.
What you can do is to pass error information back to the CallRoute.
(or vise versa if you want to).

So instead of using the .class you use an instance of the bean

CSVConverterBean myConverterBean = new ...
myConverterBean.setCallRoute(this);

onException(IllegalClassFormatException.class).handled(true).bean(myConverterBean,
"validationFailed).end();

And then in the validationFailed method, you can access the CallRoute
instance as you passed to it using the setter setCallRoute.
Then you can call a method on CallRoute to pass in error details.




On Thu, Aug 11, 2011 at 9:40 AM, aum.struts <aum.struts@gmail.com> wrote:
> While going through the Documents it has been wriiten that the exception or
> custom message will be show back to caller
>
> i am confused what exactly caller in this case.
> Since my route is being executed by the camel itself so its camel who is
> caller?
>
> For e.g
> in my routebuilder class
>
> public class CallRoute {
> public void callRoute() throws Exception{
> CamelContext context = new DefaultCamelContext();
> context.addRoutes(new RouteBuilder() {
>
>                                  public void configure() {
>
> onException(IllegalClassFormatException.class).handled(true).bean(CSVConverterBean.class,
> "validationFailed).end();
>
> from("file:data/csv?fileName=input-customer2.csv").unmarshal().csv()
>                                         .bean(new
> CSVConverterBean(),"processCSVInvoice").to("xslt:http://localhost:7777/struts2/styles/XMLConverter.xsl").to("file:data/csvoutput?fileName=test11.xml");
>                                 }
>                            });
>                context.start();
>            Thread.sleep(10000);
>
>            context.stop();
>        }
> }
> and i am calling callRoute() method from my main method in another class.
> so in case IllegalClassFormatException onException() method will be called
> and which in turn will pass the things to CSVConverterBean.class,
> "validationFailed method.
>
> So i can i pass the status back to main method?
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/camel-Error-Handling-tp4681829p4688705.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Mime
View raw message