You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2021/07/30 03:13:11 UTC

[GitHub] [camel] ttyy1112 opened a new pull request #5890: FIX: can not use endChoice() in nest choice DSL

ttyy1112 opened a new pull request #5890:
URL: https://github.com/apache/camel/pull/5890


   Detail: https://issues.apache.org/jira/browse/CAMEL-16825
   
   <!-- Uncomment and fill this section if your PR is not trivial
   - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it).  Trivial changes like typos do not require a JIRA issue.  Your pull request should address just this issue, without pulling in other changes.
   - [ ] Each commit in the pull request should have a meaningful subject line and body.
   - [ ] If you're unsure, you can format the pull request title like `[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the appropriate JIRA issue.
   - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [ ] Run `mvn clean install -Psourcecheck` in your module with source check enabled to make sure basic checks pass and there are no checkstyle violations. A more thorough check will be performed on your pull request automatically.
   Below are the contribution guidelines:
   https://github.com/apache/camel/blob/main/CONTRIBUTING.md
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] davsclaus commented on pull request #5890: FIX: can not use endChoice() in nest choice DSL

Posted by GitBox <gi...@apache.org>.
davsclaus commented on pull request #5890:
URL: https://github.com/apache/camel/pull/5890#issuecomment-889627026


   This causes problems, you should have run the unit tests of camel-core first.
   
   If you enable dump routes, you can better see the model
   
        context.setDumpRoutes(true);
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] ttyy1112 commented on pull request #5890: FIX: can not use endChoice() in nest choice DSL

Posted by GitBox <gi...@apache.org>.
ttyy1112 commented on pull request #5890:
URL: https://github.com/apache/camel/pull/5890#issuecomment-889760939


   > This causes problems, you should have run the unit tests of camel-core first.
   > 
   > If you enable dump routes, you can better see the model
   > 
   > ```
   >  context.setDumpRoutes(true);
   > ```
   
   Well, I just saw the test case about EIP choice, It seems like that endChoice() is pair of choice(), but in some situation it does not, such as when you add another EIP DSL in you when clause, you should also add the endChoice() after when clause. So in when or otherwise clause, I have to decide in advance use endChoice() or not . 
   
   Sometimes, I want to generate the Java-DSL dynamically and I don't know how many nest choices  it will be, and also have no idea whether there is another EIP DSL in the when clause or not. So In this case, I hope the choice clause  below would always work.
   
   .choice()
     .when().log().endChoice()
     .when().log().endChoice()
     .otherwise().log().endChoice()
   .end()
     
   Though a little redundancy, I think it will simple in use.
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] ttyy1112 edited a comment on pull request #5890: FIX: can not use endChoice() in nest choice DSL

Posted by GitBox <gi...@apache.org>.
ttyy1112 edited a comment on pull request #5890:
URL: https://github.com/apache/camel/pull/5890#issuecomment-889760939


   > This causes problems, you should have run the unit tests of camel-core first.
   > 
   > If you enable dump routes, you can better see the model
   > 
   > ```
   >  context.setDumpRoutes(true);
   > ```
   
   Well, As the endChoice() javadoc described: 
   
   If you want to end the entire choice block, then use end() instead. The purpose of endChoice() is to return control back to the choice() DSL, so you can add subsequent when and otherwise to the choice. 
   
   Now, consider the to DSL below. DSL-TWO looks more regular and well-organized, but it does not work.
   DSL-ONE:
     from("direct:start")
       .choice()
           .when(header("foo").isGreaterThan(1))
               .choice()
                   .when(header("foo").isGreaterThan(5)).to("mock:big")
                   .otherwise().to("mock:med")
           .endChoice()
           .otherwise().to("mock:low")
       .end();
   
   DSL-TWO:
     from("direct:start")
       .choice()
           .when(header("foo").isGreaterThan(1))
               .choice()
                   .when(header("foo").isGreaterThan(5)).to("mock:big").endChoice()
                   .otherwise().to("mock:med").endChoice()
               .end()
           .endChoice()
           .otherwise().to("mock:low").endChoice()
       .end();
   
   To make nest choice work, we must remember the most outer choice should end by end() method, while inner choice must end with endChoice() method and the most inner choice must not include enChoice() in both when and otherwise clause.
   It's not end, if you have another EIP DSL in your most inner when or otherwise clause, endChoice() is needed. 
   
   There are so many rules you should remember! Sometimes, I want to generate the Java-DSL dynamically and I don't know how many nest choices  it will be, and also have no idea whether there is another EIP DSL in the when clause or not. So In this case, I hope the choice clause  below would always work. (eg. DSL-TWO)
   
   .choice()
     .when().log().endChoice()
     .when().log().endChoice()
     .otherwise().log().endChoice()
   .end()
     
   Though a little redundancy, I think it will simple in use.
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] ttyy1112 closed pull request #5890: FIX: can not use endChoice() in nest choice DSL

Posted by GitBox <gi...@apache.org>.
ttyy1112 closed pull request #5890:
URL: https://github.com/apache/camel/pull/5890


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] ttyy1112 closed pull request #5890: FIX: can not use endChoice() in nest choice DSL

Posted by GitBox <gi...@apache.org>.
ttyy1112 closed pull request #5890:
URL: https://github.com/apache/camel/pull/5890


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] ttyy1112 edited a comment on pull request #5890: FIX: can not use endChoice() in nest choice DSL

Posted by GitBox <gi...@apache.org>.
ttyy1112 edited a comment on pull request #5890:
URL: https://github.com/apache/camel/pull/5890#issuecomment-889760939


   > This causes problems, you should have run the unit tests of camel-core first.
   > 
   > If you enable dump routes, you can better see the model
   > 
   > ```
   >  context.setDumpRoutes(true);
   > ```
   
   Well, to make my change work, I have to make some change of the failed test case.
   
   And I think we should take a further discussion why I want to change the code like this. 
   
   As the endChoice() javadoc described: 
   If you want to end the entire choice block, then use end() instead. The purpose of endChoice() is to return control back to the choice() DSL, so you can add subsequent when and otherwise to the choice. 
   
   Now, consider the to DSL below. DSL-TWO looks more regular and well-organized, but it does not work.
   DSL-ONE:
     from("direct:start")
       .choice()
           .when(header("foo").isGreaterThan(1))
               .choice()
                   .when(header("foo").isGreaterThan(5)).to("mock:big")
                   .otherwise().to("mock:med")
           .endChoice()
           .otherwise().to("mock:low")
       .end();
   
   DSL-TWO:
     from("direct:start")
       .choice()
           .when(header("foo").isGreaterThan(1))
               .choice()
                   .when(header("foo").isGreaterThan(5)).to("mock:big").endChoice()
                   .otherwise().to("mock:med").endChoice()
               .end()
           .endChoice()
           .otherwise().to("mock:low").endChoice()
       .end();
   
   To make nest choice work, we must remember the most outer choice should end by end() method, while inner choice must end with endChoice() method and the most inner choice must not include enChoice() in both when and otherwise clause.
   It's not end, if you have another EIP DSL in your most inner when or otherwise clause, endChoice() is needed. 
   
   There are so many rules you should remember! Sometimes, I want to generate the Java-DSL dynamically and I don't know how many nest choices  it will be, and also have no idea whether there is another EIP DSL in the when clause or not. So In this case, I hope the choice clause  below would always work. (eg. DSL-TWO)
   
   .choice()
     .when().log().endChoice()
     .when().log().endChoice()
     .otherwise().log().endChoice()
   .end()
     
   Though a little redundancy, I think it will simple in use.
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] ttyy1112 edited a comment on pull request #5890: FIX: can not use endChoice() in nest choice DSL

Posted by GitBox <gi...@apache.org>.
ttyy1112 edited a comment on pull request #5890:
URL: https://github.com/apache/camel/pull/5890#issuecomment-889760939


   Well, to make my change work, I have to make some change of the failed test case.
   
   And I think we should take a further discussion why I want to change the code like this. 
   
   As the endChoice() javadoc described: 
   If you want to end the entire choice block, then use end() instead. The purpose of endChoice() is to return control back to the choice() DSL, so you can add subsequent when and otherwise to the choice. 
   
   Now, consider the to DSL below. DSL-TWO looks more regular and well-organized, but it does not work.
   DSL-ONE:
     from("direct:start")
       .choice()
           .when(header("foo").isGreaterThan(1))
               .choice()
                   .when(header("foo").isGreaterThan(5)).to("mock:big")
                   .otherwise().to("mock:med")
           .endChoice()
           .otherwise().to("mock:low")
       .end();
   
   DSL-TWO:
     from("direct:start")
       .choice()
           .when(header("foo").isGreaterThan(1))
               .choice()
                   .when(header("foo").isGreaterThan(5)).to("mock:big").endChoice()
                   .otherwise().to("mock:med").endChoice()
               .end()
           .endChoice()
           .otherwise().to("mock:low").endChoice()
       .end();
   
   To make nest choice work, we must remember the most outer choice should end by end() method, while inner choice must end with endChoice() method and the most inner choice must not include enChoice() in both when and otherwise clause.
   It's not end, if you have another EIP DSL in your most inner when or otherwise clause, endChoice() is needed. 
   
   There are so many rules you should remember! Sometimes, I want to generate the Java-DSL dynamically and I don't know how many nest choices  it will be, and also have no idea whether there is another EIP DSL in the when clause or not. So In this case, I hope the choice clause  below would always work. (eg. DSL-TWO)
   
   .choice()
     .when().log().endChoice()
     .when().log().endChoice()
     .otherwise().log().endChoice()
   .end()
     
   Though a little redundancy, I think it will simple in use.
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel] ttyy1112 edited a comment on pull request #5890: FIX: can not use endChoice() in nest choice DSL

Posted by GitBox <gi...@apache.org>.
ttyy1112 edited a comment on pull request #5890:
URL: https://github.com/apache/camel/pull/5890#issuecomment-889760939


   Well, to make my change work, I have to make some change of the failed test case.
   
   And I think we should take a further discussion why I want to change the code like this. 
   
   As the endChoice() javadoc described: 
   If you want to end the entire choice block, then use end() instead. The purpose of endChoice() is to return control back to the choice() DSL, so you can add subsequent when and otherwise to the choice. 
   
   Now, consider the to DSL below. DSL-TWO looks more regular and well-organized, but it does not work.
   DSL-ONE:
     from("direct:start")
       .choice()
           .when(header("foo").isGreaterThan(1))
               .choice()
                   .when(header("foo").isGreaterThan(5)).to("mock:big")
                   .otherwise().to("mock:med")
           .endChoice()
           .otherwise().to("mock:low")
       .end();
   
   DSL-TWO:
     from("direct:start")
       .choice()
           .when(header("foo").isGreaterThan(1))
               .choice()
                   .when(header("foo").isGreaterThan(5)).to("mock:big").endChoice()
                   .otherwise().to("mock:med").endChoice()
               .end()
           .endChoice()
           .otherwise().to("mock:low").endChoice()
       .end();
   
   To make nest choice work, we must remember the most outer choice should end by end() method, while inner choice must end with endChoice() method and the most inner choice must not include enChoice() in both when and otherwise clause.
   It's not end, if you have another EIP DSL in your most inner when or otherwise clause, endChoice() is needed. 
   
   There are so many rules you should remember! Sometimes, I want to generate the Java-DSL dynamically and I don't know how many nest choices  it will be, and also have no idea whether there is another EIP DSL in the when clause or not. So In this case, I hope the choice clause  below would always work. (eg. DSL-TWO)
   
   .choice()
     .when().log().endChoice()
     .when().log().endChoice()
     .otherwise().log().endChoice()
   .end()
     
   Though a little redundancy, I think it will simple in use.
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org