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/12/01 12:14:12 UTC

[jira] [Commented] (CAMEL-8097) Error in AST/Graph translation

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

Claus Ibsen commented on CAMEL-8097:
------------------------------------

Its actually correct in Camel. The endChoice is not ending the block, but returns the "control" back to the choice DSL. So you are on the same level, and therefor the log:last is on same level as the choice. You should use .end() instead.

eg .endChoice is only needed if you do more complicated EIP routing in a when block, and need to end that block, but get back to the choice, so you can add another when etc.

      .when(simple("something"))
                            .to("direct:a")
                           ... // more complicated eip stuff here
                   .endChoice()
      // need to use endChoice so we can get back to using .when()
      .when(simple("blabla"))
   

> Error in AST/Graph translation
> ------------------------------
>
>                 Key: CAMEL-8097
>                 URL: https://issues.apache.org/jira/browse/CAMEL-8097
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.14.0
>            Reporter: Paolo Antinori
>            Assignee: Claus Ibsen
>             Fix For: 2.14.1, 2.15.0
>
>
> See https://github.com/hawtio/hawtio/issues/1202
> There could be a problem in {{camel-core}} with the graph model generation, in presence of multiple {{end()}} calls.
> {code:java}
>         from("direct:whatever")
>                 .split(body()).parallelProcessing().streaming()
>                     .setHeader("", simple(""))
>                     .process(new Processor() {
>                         @Override
>                         public void process(Exchange exchange) throws Exception {
>                             
>                         }
>                     })
>                     .choice()
>                         .when(simple("something"))
>                             .to("direct:a")
>                         .when(simple("something2"))
>                             .to("direct:b")
>                         .when(simple("something3"))
>                             .to("direct:c")
>                         .otherwise()
>                             .log("whatever")
>                     .end()
>                 .end()
>                 .log("very last");
> {code}
> Produces the equivalent of this xml dump:
> {code:xml}
> <route xmlns="http://camel.apache.org/schema/spring" id="route2">
>         <from uri="direct:whatever1"/>
>         <split parallelProcessing="true" streaming="true">
>             <expressionDefinition>body</expressionDefinition>
>             <setHeader headerName="">
>                 <simple/>
>             </setHeader>
>             <process/>
>             <choice>
>                 <when>
>                     <simple>something</simple>
>                     <to uri="direct:a"/>
>                 </when>
>                 <when>
>                     <simple>something2</simple>
>                     <to uri="direct:b"/>
>                 </when>
>                 <when>
>                     <simple>something3</simple>
>                     <to uri="direct:c"/>
>                 </when>
>                 <otherwise>
>                     <log message="whatever"/>
>                 </otherwise>
>             </choice>
>         </split>
>         <log message="very last"/>
>     </route>
> {code}
> while using *{{endChoice()}}* in place of the inner *{{end()}}*
> it produces:
> {code:xml}
> <route xmlns="http://camel.apache.org/schema/spring" id="route3">
>         <from uri="direct:whatever2"/>
>         <split parallelProcessing="true" streaming="true">
>             <expressionDefinition>body</expressionDefinition>
>             <setHeader headerName="">
>                 <simple/>
>             </setHeader>
>             <process/>
>             <choice>
>                 <when>
>                     <simple>something</simple>
>                     <to uri="direct:a"/>
>                 </when>
>                 <when>
>                     <simple>something2</simple>
>                     <to uri="direct:b"/>
>                 </when>
>                 <when>
>                     <simple>something3</simple>
>                     <to uri="direct:c"/>
>                 </when>
>                 <otherwise>
>                     <log message="whatever"/>
>                 </otherwise>
>             </choice>
>             <log message="very last"/>
>         </split>
>     </route>
> {code}
> Where the difference is in the location of the line *<log message="very last"/>*
> Is this behavior correct? or should this work already without the need of *{{endChoice()}}* statement?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)