You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Hadrian Zbarcea (JIRA)" <ji...@apache.org> on 2008/06/17 15:57:00 UTC

[jira] Issue Comment Edited: (CAMEL-612) Exchange should end in error when no choice in a ChoiceType matches

    [ https://issues.apache.org/activemq/browse/CAMEL-612?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43527#action_43527 ] 

hadrian edited comment on CAMEL-612 at 6/17/08 6:55 AM:
----------------------------------------------------------------

-1 [edit: retracting my +1]

In other words if there is no explicit otherwise() to go the errorHandler (no redelivery of course).

Thinking more about this I think the behavior of choice should be the way it already is.  If no clause matches and there is no otherwise it should silently succeed with a noop.  Users are familiar with this from switch() statements and is i think a reasonable expectation.

I think it's perfectly reasonable to add the otherwise (as one would add a default: ) to make it explicit that the exchange should fail if there is no match:

{code}
    [...].otherwise().exception(MyException.class);
{code}

What I would do though is adding a log (below INFO) in the ChoiceProcessor.process() if otherwise == null that would say that exchange is not processed.

      was (Author: hadrian):
    +1 
In other words if there is no explicit otherwise() to go the errorHandler (no redelivery of course).  I think that makes sense.
  
> Exchange should end in error when no choice in a ChoiceType matches
> -------------------------------------------------------------------
>
>                 Key: CAMEL-612
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-612
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 1.3.0
>            Reporter: Gert Vanthienen
>            Assignee: Gert Vanthienen
>
> When you define a route with a choice() and no matching when() clause is found, the Exchange just ends successfully without doing anything.  In my mind, it should fail by default in this case (or we should at least have an easy way to get this behavior).
> {code}
> from(DIRECT_ROUTER).choice()
>   .when(xpath("/oc:order_confirmation/oc:order/oc:customer/@category = '140'"))
>     .to(DIRECT_CUSTOMER1)
>   .when(xpath("/oc:order_confirmation/oc:order/oc:customer/@category = '116'"))
>     .to(DIRECT_CUSTOMER2);
> {code}

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