0 Replies Latest reply on Sep 5, 2012 2:11 PM by Christopher Britz

    Smooks with JBoss ESB not Splitting Messages and/or Routing at All

    Christopher Britz Newbie

      So I have been given the opportunity to take a huge ESB message and split it to smaller esb messages for processing.  However, when I try to do a simple split and route Smooks doesnt want to split it up.  I am new to Smooks, so its probably a user error.  So I was wondering if someone can take a look at what I have, and maybe an extra set of eyes is all I need.  Also, I am guessing on this, but I think my problem is with my ESB that calls apon smooks because I try to use the Smooks FileStreamSplitter class on a JMS Queue.  So first, can that be done?  I havent seen any documentation that states otherwise.

       

      Here is my ESB that calls the Smooks FileStreamSplitter.xml:

       

      <?xml version = "1.0" encoding = "UTF-8"?>
      <jbossesb
                xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd http://anonsvn.jboss.org/repos/labs/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd"
                parameterReloadSecs="5">
      
      
                <providers>
      
      
                          <jms-provider name="JBossMQ" connection-factory="ConnectionFactory"
                                    jndi-URL="jnp://localhost:1099" jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
                                    jndi-pkg-prefix="org.jboss.naming:org.jnp.interfaces">
                                    <jms-bus busid="newProductsEsbChannel">
                                              <jms-message-filter dest-type="QUEUE"
                                                        dest-name="queue/transformNewProducts" />
                                    </jms-bus>
                          </jms-provider>
      
      
                </providers>
      
      
                <services>
                          <service category="transforms" name="new_product" description="jms listeners"
                                    invmScope="GLOBAL">
                                    <listeners>
                                              <jms-listener name="new_prod_jms_lstnr" busidref="newProductsEsbChannel">
                                                         <property name="composer-class" value="org.jboss.soa.esb.smooks.splitting.FileStreamSplitter"/>
                          <property name="splitterConfig" value="/smooks-config.xml"/>
                          <property name="reportPath" value="/zap/report.html"/>
                      </jms-listener>
                                    </listeners>
                                    <actions mep="OneWay">
        
                                              <action name="print-before" class="org.jboss.soa.esb.actions.SystemPrintln">
                                                        <property name="message" value="Message before transformation" />
                                              </action>
        
                                    </actions>
                          </service>
        
                          <service category="transforms" name="split_products" description="split messages"
                                    invmScope="GLOBAL">
                                    <actions>
                                              <action name="print-after" class="org.jboss.soa.esb.actions.SystemPrintln">
                                                        <property name="message" value="Message after transformation" />
                                              </action>
                                    </actions>
                          </service>
        
                </services> 
      
      
      </jbossesb>
      

       

       

      Here is my smooks-config.xml:

      <?xml version="1.0"?>
      <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
                            xmlns:jb="http://www.milyn.org/xsd/smooks/javabean-1.1.xsd"
                            xmlns:ftl="http://www.milyn.org/xsd/smooks/freemarker-1.1.xsd"
                            xmlns:esbr="http://www.jboss.org/xsd/jbossesb/smooks/routing-1.0.xsd"
                            xmlns:jms="http://www.milyn.org/xsd/smooks/jms-routing-1.2.xsd">
                            
          <params>        
              <param name="stream.filter.type">SAX</param>
          </params>
      
        <!-- Capture the message data 2 seperate DOM models, for "order" and "order-item" fragments... -->
          <resource-config selector="newproducts, product">
              <resource>org.milyn.delivery.DomModelCreator</resource>
          </resource-config>
      
        
          <!-- On each order-item, apply a template to the data captured into the bean context,
               binding the templating result back into the bean context under the
               beanId "orderItemFragment" to be routed by the following ESB Router... -->
          <ftl:freemarker applyOnElement="newproducts">
              <ftl:template>
              <!--<newproducts>
                                                                            <datecreated>${newproducts.datecreated}</datecreated>
                                                                            <createdby>${newproducts.createdby}</createdBy>
                                                                            <catsdistributionid>${newproducts.catsdistributionid}</catsdistributionid>
                                                                            <products>
                                                                                      <?TEMPLATE-SPLIT-PI?>
                                                                            </products>
                                                                    </newproducts>-->
                               <ftl:use>
                  <ftl:bindTo id="productFragment" />
                        </ftl:use>
        </ftl:template>
          </ftl:freemarker>
          
          <ftl:freemarker applyOnElement="product">
              <ftl:template>
              <!--<product  ${productType.@type}>
                                  <catsbookid>${product.catsbookid}</catsbookid>
                        </product>-->
              </ftl:template>
          </ftl:freemarker>
          
      <!--      On each order-item, route the "orderItemFragment" bean to the  -->
          <esbr:routeBean beanIdRef="productFragment" toServiceCategory="transforms" toServiceName="split_products" routeOnElement="product" >
          </esbr:routeBean>
      </smooks-resource-list>
      
      
      

       

       

      Here is my test xml file that I use to test splitting the document up.  I am trying to split up the products in their own newproduct message:

       

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <newproducts xmlns="urn:ithaka.org:cm:new_products:1_0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ithaka.org:cm:new_products:1_0 new_products-1_0.xsd">
          <datecreated>2012-08-01</datecreated>
          <createdby>jhirschman</createdby>
          <catsdistributionid>22573-cttbfqg8</catsdistributionid>
          <products>
              <product type="book">
                  <catsbookid>22573/cttbch6f</catsbookid>
                  <literatumid></literatumid>
                  <eisbn13>9780773586796</eisbn13>
                  <pisbn13>9780773540316</pisbn13>
                  <title>Leave No Doubt</title>
                  <subtitle>A Credo for Chasing Your Dreams</subtitle>
                  <set>
                      <ltmsetid></ltmsetid>
                      <settitle></settitle>
                      <setvolume></setvolume>
                  </set>
                  <series>
                      <ltmseriesid>10.5555/books</ltmseriesid>
                      <seriestitle>Default Book Series</seriestitle>
                      <seriesvolume></seriesvolume>
                  </series>
                  <editiontype></editiontype>
                  <editionnumber></editionnumber>
                  <editionversion></editionversion>
                  <publicationdate>2012-03-20</publicationdate>
                  <ltmbookspublishercode>mqup</ltmbookspublishercode>
                  <ktekbookspublishercode>FM-V01343</ktekbookspublishercode>
                  <ltmimprintcode></ltmimprintcode>
                  <bisac length="1">
                      <code>BUS000000</code>
                  </bisac>
                  <disciplines>
                      <discipline ordinal="1">business-discipline</discipline>
                  </disciplines>
                  <lccallnumber></lccallnumber>
                  <prices>
                      <limitedprice>14.95</limitedprice>
                      <limitedpricecurrency>USD</limitedpricecurrency>
                      <unlimitedpricespecialinstructions></unlimitedpricespecialinstructions>
                      <unlimitedprice type="none"></unlimitedprice>
                      <unlimitedpricecurrency></unlimitedpricecurrency>
                      <downloadpack type="percent">20</downloadpack>
                      <downloadpackcurrency>USD</downloadpackcurrency>
                  </prices>
                  <language>eng</language>
                  <originallanguage></originallanguage>
                  <copyrightyear></copyrightyear>
                  <numberofpages>146</numberofpages>
                  <contributors>
                      <contributor>
                          <surname>Babcock</surname>
                          <givennames>Mike</givennames>
                          <prefix></prefix>
                          <suffix></suffix>
                          <collab></collab>
                          <stringname>Babcock, Mike</stringname>
                          <sequence>1</sequence>
                          <contribtype>A01</contribtype>
                      </contributor>
                      <contributor>
                          <surname>Larsen</surname>
                          <givennames>Rick</givennames>
                          <prefix></prefix>
                          <suffix></suffix>
                          <collab></collab>
                          <stringname>Larsen, Rick</stringname>
                          <sequence>2</sequence>
                          <contribtype>A02</contribtype>
                      </contributor>
                  </contributors>
              </product> 
              <product type="book">
                  <catsbookid>22573/cttbchs2</catsbookid>
                  <literatumid></literatumid>
                  <eisbn13>9780773573871</eisbn13>
                  <pisbn13>9780886292263</pisbn13>
                  <title>Canada Among Nations, 1994</title>
                  <subtitle>A Part of the Peace</subtitle>
                  <set>
                      <ltmsetid></ltmsetid>
                      <settitle></settitle>
                      <setvolume></setvolume>
                  </set>
                  <series>
                      <ltmseriesid>10.2307/j.ctt7mspn</ltmseriesid>
                      <seriestitle>Canada Among Nations Series</seriestitle>
                      <seriesvolume></seriesvolume>
                  </series>
                  <editiontype></editiontype>
                  <editionnumber></editionnumber>
                  <editionversion></editionversion>
                  <publicationdate>1994-06-15</publicationdate>
                  <ltmbookspublishercode>mqup</ltmbookspublishercode>
                  <ktekbookspublishercode>FM-V01343</ktekbookspublishercode>
                  <ltmimprintcode></ltmimprintcode>
                  <bisac length="1">
                      <code>HIS006000</code>
                  </bisac>
                  <disciplines>
                      <discipline ordinal="1">history-discipline</discipline>
                  </disciplines>
                  <lccallnumber></lccallnumber>
                  <prices>
                      <limitedprice>95.0</limitedprice>
                      <limitedpricecurrency>USD</limitedpricecurrency>
                      <unlimitedpricespecialinstructions></unlimitedpricespecialinstructions>
                      <unlimitedprice type="none"></unlimitedprice>
                      <unlimitedpricecurrency></unlimitedpricecurrency>
                      <downloadpack type="percent">20</downloadpack>
                      <downloadpackcurrency>USD</downloadpackcurrency>
                  </prices>
                  <language>eng</language>
                  <originallanguage></originallanguage>
                  <copyrightyear></copyrightyear>
                  <numberofpages>384</numberofpages>
                  <contributors>
                      <contributor>
                          <surname>Molot</surname>
                          <givennames>Maureen Appel</givennames>
                          <prefix></prefix>
                          <suffix></suffix>
                          <collab></collab>
                          <stringname>Molot, Maureen Appel</stringname>
                          <sequence>1</sequence>
                          <contribtype>A01</contribtype>
                      </contributor>
                      <contributor>
                          <surname>Von Riekhoff</surname>
                          <givennames></givennames>
                          <prefix></prefix>
                          <suffix></suffix>
                          <collab></collab>
                          <stringname>Von Riekhoff</stringname>
                          <sequence>2</sequence>
                          <contribtype>A01</contribtype>
                      </contributor>
                  </contributors>
              </product>
              
          </products>
      </newproducts>
      
      
      
      

       

      I have tried to use both the samples within jboss esb directory as well as smooks documentation.

       

       

      If you need anymore info please let me know as I would not post anything on the forums unless it was absolutely necessary.