Hi,
I think you can use the ErrorHandler to catch the Exception in a genetical way.
What's your ProcessError class looks like?


-- 
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) 
(English)
          http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang 
Weibo: willemjiang





On Thursday, October 18, 2012 at 10:39 PM, snowindy wrote:

> Dear experienced Camel users! Please tell me
> 
> *1) What is wrong in my design in general? (I am sure it is not optimal)
> 2) What is a correct way to use POJOs in an Exchange body?*
> 
> My Grails web-application needs to interact to a remote web-service with
> some intermediate steps:
> 
> -Create request xml
> -Validate this xml
> -Sign xml with dsig
> -Send signed xml to ths web-service
> -Validate response signature
> -Validate response XML
> -Process response
> 
> Each step may throw an exception, which must be shown at a page. Like this:
> "Error occured at step StepName, error message: Message".
> 
> So I guess my preferable pattern is "Request-Reply".
> 
> I am trying to assemble a camel route using a set of processors. Each
> processor is wrapped in .doTry() like this one.
> 
> *from("direct:sendServiceCatalog")
> .doTry()
> .process(new Processor() {
> 
> @Override
> public void process(Exchange arg0) throws Exception {
> System.out.println("PROCESSING");
> throw new RuntimeException("Nice try");
> 
> }
> })
> .to("mock:result")
> .doCatch(Exception.class)
> .process(
> new ExceptionStageDetectorProcessor(
> SendServiceCatalogStage.FORM_XML))
> .to("mock:catch")
> .end();*
> 
> 
> ExceptionStageDetectorProcessor.java class is pretty simple:
> 
> *public class ExceptionStageDetectorProcessor implements Processor {
> 
> public ExceptionStageDetectorProcessor(SendServiceCatalogStage stage) {
> this.stage = stage;
> }
> 
> public SendServiceCatalogStage getStage() {
> return stage;
> }
> 
> private SendServiceCatalogStage stage;
> 
> @Override
> public void process(Exchange exchange) throws Exception {
> Throwable caughtException = (Throwable) exchange
> .getProperty(Exchange.EXCEPTION_CAUGHT);
> 
> exchange.getOut().setBody(new ProcessError(stage, caughtException));
> }
> }
> *
> 
> It almost worked! :)
> 
> The problem is that the new body ProcessError cannot be used, when exception
> occurs returning object is an error string, not a ProcessError object. If I
> try to set a simple string .setBody("FOO") returning object is "FOO"
> exactly.
> 
> 
> 
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Camel-application-design-question-tp5721248.html
> Sent from the Camel - Users mailing list archive at Nabble.com 
> (http://Nabble.com).



Reply via email to