Hi

The Camel scala DSL could use some love from some Scala fans. So any
contributions and improvements is welcome.



On Fri, May 23, 2014 at 12:59 PM, Christophe Pache
<[email protected]> wrote:
> Hello everyone,
>
> I'm currently working on error clauses and I got some strange behaviour with
> camel in Scala. I would really enjoy having some feedback on what I've tried
> to do because I haven't found any help on that. I saw Java example that
> seamed to work and it's really currious for me.
>
>
>  My Problem is to separate the exception handling route from the main route.
> I know this is not realistic use. I would like to have a main route such as
> : from(direct).process.to(mock) while allowing the IllegalArgumentException
> to continue the main flow. The following code doesn't compile with error
> "value to is not a member of ?0". When I try to separate the route into
> separated parts, the type gets to Any instead of ProcessorDefinition of Any
> which I thing could be the error. I don't get this compilation error if I
> remove the processor from the route.
>
>     class MyRoute extends RouteBuilder {
>
>       def configure() {
>
>         val exceptionProcessor = new Processor {
>           def process(ex: Exchange) {
>             throw ex.getIn.getBody(classOf[Exception])
>           }
>         }
>
> from("direct:input").onException(classOf[IllegalArgumentException])
> .continued(true).end().process(exceptionProcessor).to("mock:toto")
>
>       }
>     }
>
> Even harder to understand, the following is working well:
>
> def configure() {
>
>         val exceptionProcessor = new Processor {
>           def process(ex: Exchange) {
>             throw ex.getIn.getBody(classOf[Exception])
>           }
>         }
>
>         onException(classOf[IllegalArgumentException]).continued(new
> Predicate {
>           override def matches(exchange: Exchange): Boolean = {
> exchange.getIn().getBody(classOf[Exception]).getMessage.contains("toto")
>           }
>         })
>
> from("direct:input").process(exceptionProcessor).to("mock:output")
>       }
>     }
>
> Thanks a lot for any comment/help.
>
> Christophe



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [email protected]
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Reply via email to