5 Replies Latest reply on Jul 17, 2009 12:47 PM by oisin

    Splitter issue

    italost

      I need to implement my own splitter rule. I need to split a message after a processor. I am trying to use

       

                from("cxf:someService")

                .process(new MyFirstProcessor())

                .splitter(true).method("someBean")

                .process(new MySecondProcessor())

                .to("log:someLog");

       

      It gives me a compile error:

       

         The method process(MySecondProcessor()) is undefined for the type Object

       

      If I remove the first processor, it compiles

       

                from("cxf:someService")

                .splitter(true).method("someBean")

                .process(new MySecondProcessor())

                .to("log:someLog");

       

      If I use another type of splitter, like

         splitter(header("recipientList").tokenize(";"),true)

      it aslo works.

       

      I can solve this problem splitting (ironic, hun?) the route:

       

                from("cxf:someService")

                .process(new MyFirstProcessor())

                .to("direct:foo");

       

                from("direct:foo")

                .splitter(true).method("someBean")

                .process(new MySecondProcessor())

                .to("log:someLog");

       

       

      But I am really curious to know why this problem happens.

      Any idea?

       

      Regards.

       

      Italo Stefani

      Vetta Technologies

      www.vettatech.com

       

      Edited by: italost on Jul 16, 2009 7:46 PM

        • 1. Re: Splitter issue
          davsclaus

          Hi

           

          The Camel Java DSL is using the fluent builder syntax where each DSL is a method call that is stacked on top on the previous.

           

          And as such you have some limitations with the JDK itself.

           

          The JDK is not suited for full blown DSL, e.g. building a new languages. For that we got other languages such as Groovy and Scala.

           

          However that said its still pretty impressive what we can do with Camel in the Java DSL. It does resemble of a fullblown DSL but with limitations here and there.

           

          Basically when you have ctrl + space to see the opertions list after type from. you get a list from the same base class (ProcessorType). It list all the possibilities you can, eg. to, splitter, aggregate, and what else.

           

          However some of these EIP (such as splitter) have their own list of operations in their type: SplitterType. And when you get down this path the JDK cannot always "step back" so to speak.

           

          And hence you can run into a wall with how you build the Camel routes.

          • 2. Re: Splitter issue
            joe.luo

            from("cxf:someService")

            .process(new MyFirstProcessor())

            .splitter(true).method("someBean")

             

            returns an Object type whileas

             

            from("cxf:someService")

            .splitter(true).method("someBean")

             

            returns an ProcessorType type and that was why it won't compile if you continue call ".process(...)" with the former route but the later one compiles.

             

            I suggest you to use eclipse IDE so you will be prompted with correct type when you write a complex camel route like this.

            • 3. Re: Splitter issue
              oisin

              The Java fluent builder approach and the Spring XML approaches both have their advantages and drawbacks.

               

              I took your example and sketched it out with our Integration Designer - we've just released a point upgrade to 1.2.1 - and it looks like this

               

               

              which might be a big more illustrative of the route itself. The tool will allow you to run and debug your route, and export it to a Spring XML.

              • 4. Re: Splitter issue
                italost

                Thanks for the answers.

                 

                I use Eclipse ide and I have noticed the type difference.

                I was only wondering why and when the difference of types happens. At a first moment it sounded strange for me.

                 

                I found the Integration Designer pretty cool. I am register for the next webinar!!

                 

                Regards.

                 

                Italo Stefani

                Vetta Technologies

                www.vettatech.com

                 

                Edited by: italost on Jul 17, 2009 2:40 PM

                • 5. Re: Splitter issue
                  oisin

                   

                  I found the Integration Designer pretty cool. I am register for the next webinar!!

                   

                   

                  Thanks for the comment! I'll be doing the webinar on Tuesday 21st, currently practising my lines