You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (JIRA)" <ji...@apache.org> on 2014/02/08 09:38:19 UTC

[jira] [Commented] (CAMEL-7180) Support multiple onWhen + onOtherwise in onComplete blocks

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

Claus Ibsen commented on CAMEL-7180:
------------------------------------

-1
Its really 2 different things
And you should use the building blocks already. 

The onWhen on onCompletion is for only triggering the on completion when the predicate is true, eg for a single predicate.
The Content Based Router is for doing if ... elseif ... elseif ... else constructs.

You use case should be:
{code}
.onCompletion().onCompleteOnly()
    .choice()
      .onWhen(xpath("/result = 'ok'"))
          .log("All good!")
      .onWhen(xpath("/result = 'warn'"))
          .log(LoggingLevel.WARN, "Something didn't go quite as right!")
      .otherwise()
          .log(LoggingLevel.ERROR, "Something went awfully wrong!")
     .end()
.end()
{code}

> Support multiple onWhen + onOtherwise in onComplete blocks
> ----------------------------------------------------------
>
>                 Key: CAMEL-7180
>                 URL: https://issues.apache.org/jira/browse/CAMEL-7180
>             Project: Camel
>          Issue Type: New Feature
>          Components: camel-core
>    Affects Versions: 2.12.2
>            Reporter: Raul Kripalani
>            Assignee: Raul Kripalani
>
> Will allow for something like:
> {code}
> .onCompletion().onCompleteOnly()
>     .onWhen(xpath("/result = 'ok'"))
>         .log("All good!")
>     .onWhen(xpath("/result = 'warn'"))
>         .log(LoggingLevel.WARN, "Something didn't go quite as right!")
>     .onOtherwise()
>         .log(LoggingLevel.ERROR, "Something went awfully wrong!")
> .end()
> {code}
> This will specifically benefit route-level onComplete blocks, as only 1 is supported per route. Currently, if you want to take decisions, you have to create a nested choice() which feels clumsy, given that the onComplete DSL already supports some degree of decision-making.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)