5 Replies Latest reply on Mar 25, 2014 3:25 PM by kbjorndahl

    Adding camel module to switchyard

    kbjorndahl

      Hi Folks.

       

      I'm Running Switchyard 1.1.0 on AS 6.1 and having a little trouble adding the flatpack module to Camel.  I'm following the documentation found here and running in to some problems.

       

      I've created a flatpack/main directory under modules/system/layers/soa/org/apache/camel/ and included the flatpack-3.2.0.jar file in modules/system/layers/soa/org/apache/camel/flatpack/main.  I've created a module.xml file (attached), and updated the standalone.xml file to include:

      <extension> identifier="org.apache.camel.flatpack"/>

       

      and included in my camel service

      .to("flatpack:fixed"PCode.pzmap.xml")

       

      but on deployment I get an error "No component found with scheme: flatpack"

       

      I get the sense I'm missing something, but that's all there is supposed to be to it according to the documentation.

        • 1. Re: Adding camel module to switchyard
          kcbabo

          You have flatpack in your module definition but not the camel-flatpack component.  You can include both jars in the same module definition (two resource definitions) or split them into two modules and add a dependency on the flatpack module from the camel-flatpack module.

          1 of 1 people found this helpful
          • 2. Re: Adding camel module to switchyard
            kbjorndahl

            Thanks Keith.

             

            So, this is about day 3 for me looking at SwitchYard (after becoming quite familiar with JBoss ESB), so I apologize if I'm a little slow here.

             

            Both jars you say :-)  So, the first Jar is the flatpack-3.2.0.jar file I downloaded from the Camel site.  What is this second .jar file you speak of, and where do I find it?  Is it a switchyard specific .jar file, or does it come from the camel project?

             

            Thanks in advance,

            Keith Bjorndahl

            • 3. Re: Adding camel module to switchyard
              kcbabo

              There are two layers to this onion:

               

              1. Flatpack is a standalone Java library for parsing structured data in files.  http://flatpack.sourceforge.net/
              2. Camel Flatpack is a Camel component which wraps Flatpack so it can be used within Camel. http://camel.apache.org/flatpack.html

               

              To use flatpack inside of Camel, you need (1) and (2).  Since Camel has not had a 3.2 release and Flatpack has, I would wager you have the Flatpack jar right now.  You could do a jar listing on the archive to confirm which classes are inside.  The Camel distro should have the camel-flatpack component in it, but you can also grab it directly from Maven:

               

              http://search.maven.org/#artifactdetails%7Corg.apache.camel%7Ccamel-flatpack%7C2.10.3%7Cbundle

               

              hth,

              keith

              • 4. Re: Adding camel module to switchyard
                kbjorndahl

                That indeed took care of the problem.

                 

                If I may impose on you for one more detail, on the off chance that you've at some point used Flatpack within SwitchYard.

                 

                I assume my service will have something similar to:

                <from uri="switchyard://SomeServiceInterface" />

                <to uri="flatpack:fixed:some.pzmap.xml" />

                 

                Assuming that the .to flatpack call does indeed split my file full of records into individual messages....how do I actually do anything with them?  The documentation states that I should get back an org.apache.camel.component.flatpack.DataSetList object, but when I add an additional

                <to uri="switchyard://SomeOtherService..." /> all that service seems to receive is the original input file as a String.  I was kind of expecting a DataSetList.  Or is adding another <to uri=... /> after the flatpack call incorrect?

                • 5. Re: Adding camel module to switchyard
                  kbjorndahl

                  For anyone else who comes looking:

                   

                  It appears that you can't use the Camel (XML) implemtation but must use the Camel (Java) one, in order to be able to custom build the RouteBuilder configure() method (as shown in the Flatpack Camel documentation):

                   

                  public void configure() {

                       FlatpackDataFormat fp=new FlatpackDataFormat();

                       fp.setDefinition("some.pzmap.xml");

                       fp.setFixed(true);

                   

                       from("switchyard://SomeServiceInterface")

                       .unmarshal(fp)

                       .to("switchyard://SomeOtherService");

                   

                  THIS then sends a DataSetList object to SomeOtherService to be iterated through.

                  1 of 1 people found this helpful