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

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

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.


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

Posted by "Gert Vanthienen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-612?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gert Vanthienen resolved CAMEL-612.
-----------------------------------

    Fix Version/s: 1.4.0
                       (was: 1.5.0)
       Resolution: Fixed

I added a warning to the logging in http://svn.apache.org/viewvc?view=rev&revision=670544 and I changed the documentation at http://cwiki.apache.org/confluence/x/IcE

> 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, 1.4.0
>            Reporter: Gert Vanthienen
>            Assignee: Gert Vanthienen
>            Priority: Trivial
>             Fix For: 1.4.0
>
>
> 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.


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

Posted by "Gert Vanthienen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-612?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gert Vanthienen updated CAMEL-612:
----------------------------------

    Priority: Trivial  (was: Major)

OK, I wasn't aware of the {{throwFault()}} method that allows a user to easily make the message exchange fail instead of having to use the {{Processor}} trick.  Reducing the priority of the issue, because I guess I only need to document the default, messsage filtering behavior of the choice() on the site to make people more aware of it.  

> 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
>            Priority: Trivial
>
> 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.


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

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-612?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen updated CAMEL-612:
------------------------------

        Fix Version/s: 1.5.0
    Affects Version/s: 1.4.0

> 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, 1.4.0
>            Reporter: Gert Vanthienen
>            Assignee: Gert Vanthienen
>            Priority: Trivial
>             Fix For: 1.5.0
>
>
> 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.


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

Posted by "Hadrian Zbarcea (JIRA)" <ji...@apache.org>.
    [ 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.


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

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ 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.


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

Posted by "Hadrian Zbarcea (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-612?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43527#action_43527 ] 

Hadrian Zbarcea commented on CAMEL-612:
---------------------------------------

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


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

Posted by "Gert Vanthienen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-612?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43510#action_43510 ] 

Gert Vanthienen commented on CAMEL-612:
---------------------------------------

Claus,

I actually do think this use case for a choice() block does make sense.  I definitely do not want all my unmatched exchanges to go to any third customer, so I usually code something like:
{code}
...otherwise().process(new Processor() { //make the exchange fail here });
{code}
... to get my RouteBuilder's error handler to pick it up.

We should at least make this behavior easier to implement or maybe even make it the default when no explicit otherwise() was given.  

Gert

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


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

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-612?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43546#action_43546 ] 

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

Hadrian good comments.

>In other words if there is no explicit otherwise() to go the errorHandler (no redelivery of course).
How can we archive this, the DeadLetterChannel is probably already "chaining" the routing?

Would be good to have it documented somehow. I do think the wiki needs a section where each DSL types is documented one-by-one. That is a however a extensive work to do.

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