camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Johan Edstrom (JIRA)" <>
Subject [jira] Commented: (CAMEL-1823) doCatch(Predicate)
Date Thu, 14 Oct 2010 02:01:40 GMT


Johan Edstrom commented on CAMEL-1823:

I've been playing with this one.

It actually could be resolved with a couple of fields.
If we added a new constructor on the TryDefinition, passing in 

something like 

 public TryDefinition doCatch(Predicate predicateInTry) {
        this.predicate = predicateInTry;
        CatchDefinition answer = new CatchDefinition(RuntimeException.class);
        //CatchPredicateDefinition answer = new CatchPredicateDefinition(predicateInTry);
        return this;

And then set that field and on the TryProcessor around line 90

AsyncProcessor processor =;
            if (catchPredicateProcessor != null && catchPredicateProcessor.getCatchPredicateProcessor().getPredicate().matches(exchange))
                if (catchPredicateProcessor == processor) {
          "We should route this " + processor);
                } else {
          "We should not route this" + exchange.getUnitOfWork());
                    exchange.setException(new InternalPredicateRouteInATryCatchContext("met


We throw an internal exception, this is used from the CatchProcessor/CatchDefinition to bail
on the route.

Just an idea, but would be very un-intrusive and easy to test, it also would allow a Predicate
to run through 
as many AsyncProcessors as needed inspecting the "last" exchange for the predicate.


> doCatch(Predicate)
> ------------------
>                 Key: CAMEL-1823
>                 URL:
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-core
>            Reporter: Claus Ibsen
>             Fix For: Future
> As someone suggested on the user forum.
> Letting {{doCatch}} be able to catch and react to a predicate as well. Currently it *only*
reacts when an exception has been thrown.
> Letting it react to predicates as well will really set it high over its Java counter
> {code}
> doTry()
>    .beanRef("myBean")
>    .to("activemq:queue:foo")
> .doCatch(body().isNull())
>    .to("log:foo?level=WARN")
> .end()
> {code}

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message