2 Replies Latest reply on Jan 16, 2012 3:21 AM by labo32_delaboe

    Java DSL vs. Spring DSL

    labo32_delaboe

      Hello,

       

      I got a problem converting a route from spring dsl into java dsl.

       

      <camelContext xmlns="http://camel.apache.org/schema/spring">
          <route>
              <from uri="jms:topic:test"></from>
              <choice>
                  <when>
                      <xpath>//xml/t1</xpath>
                           <split>
                            <xpath>/xml/t1/test</xpath>
                               <to uri="log:1"></to>
                        </split>
                  </when>
                  <when>
                      <xpath>//xml/t2</xpath>
                           <split>
                            <xpath>/xml/t2/tset</xpath>
                            <to uri="log:2"></to> 
                        </split>
                  </when>
                  <otherwise>
                      <to uri="log:Invalid"></to>
                  </otherwise>
              </choice>
          </route>
      </camelContext>
      

       

      I expected a java dsl route like

       

      from("jms:topic:test")
      .choice()
             .when(xpath("//xml/t1"))
                       .split(xpath("/xml/t1/test"))
                           .to("log:1")    
             .when(xpath("//xml/t2"))
                      .split(xpath("/xml/t2/tset"))
                           .to("log:2")            
                  .otherwise()
                      .to("log:Invalid");
      

       

      but I failed with ...... a lot of possible versions.

       

      Is there a limitation in java dsl ?

       

      Thanks

      labo

        • 1. Re: Java DSL vs. Spring DSL
          davsclaus

          Yeah the Java DSL have stretched the boundaries how far you can do a DSL in regular Java language.

           

          So when you use certain EIP patterns inside a for example Content Based Router, you would need to use .end() or .endChoice() to tell the DSL when the embedded EIP is "done". In this example the .end() should be added where you would have the </split> in the XML route.

           

          There is a variation of .end() which is .endChoice() which should be used, so you get the scope of the Content Based Router.

          • 2. Re: Java DSL vs. Spring DSL
            labo32_delaboe

            Thanks ! That's it.....

             

            labo