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

Claus Ibsen commented on CAMEL-612:
-----------------------------------

Gert I do think that the choice() should *always* have an otherwise() so there 
always is a match.

{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);
  .otherwise().to(DIRECT_CUSTOMER3);
{code}

If the otherwise() is missing on the choice() then Camel should thrown an 
exception. Maybe checked during the route creation stuff.

> 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.

Reply via email to