Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-6378

Java DSL - Using transacted and onException in same route - Validate that onException is first

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.12.0
    • 2.12.0
    • camel-core
    • None
    • Unknown

    Description

      When you use Java DSL then the order how you specify transacted / policy / onException matter.

      In XML DSL (we have a chance to fix this internally in Camel, so the order there doesnt not matter as much).

      We should add validation to the Java DSL so people can configure this correctly. Otherwise we just have too much on our plate to support any kind of order of all these cross cutting functionality being used in the DSL.

      Here is an unit test that required a chance to work correctly (eg onException should be first)

      --- a/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithLocalOnExceptionT
      +++ b/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithLocalOnExceptionT
      @@ -28,22 +28,22 @@ public class TransactionalClientDataSourceTransactedWithLocalOnExceptionTest ext
               return new SpringRouteBuilder() {
                   public void configure() throws Exception {
                       from("direct:okay")
      -                    .transacted()
                           // use local on exception
                           .onException(IllegalArgumentException.class)
                               .handled(false)
                               .to("mock:error")
                           .end()
      +                    .transacted()
                           .setBody(constant("Tiger in Action")).beanRef("bookService")
                           .setBody(constant("Elephant in Action")).beanRef("bookService");
      
                       from("direct:fail")
      -                    .transacted()
                           // use local on exception
                           .onException(IllegalArgumentException.class)
                               .handled(false)
                               .to("mock:error")
                           .end()
      +                    .transacted()
                           .setBody(constant("Tiger in Action")).beanRef("bookService")
                           .setBody(constant("Donkey in Action")).beanRef("bookService");
      

      Attachments

        Issue Links

          Activity

            People

              davsclaus Claus Ibsen
              davsclaus Claus Ibsen
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: