[jboss-svn-commits] JBL Code SVN: r27991 - in labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router: src/org/jboss/soa/esb/sample/quickstart/smooksfilesplitterrouter and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Jul 14 03:43:58 EDT 2009


Author: tfennelly
Date: 2009-07-14 03:43:58 -0400 (Tue, 14 Jul 2009)
New Revision: 27991

Removed:
   labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/src/org/jboss/soa/esb/sample/quickstart/smooksfilesplitterrouter/GetFileListFromExecutionContext.java
   labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/src/org/jboss/soa/esb/sample/quickstart/smooksfilesplitterrouter/actions/
Modified:
   labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/build.xml
   labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/jboss-esb-unfiltered.xml
   labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/orderitem-split.ftl
   labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/readme.txt
   labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/smooks-config.xml
Log:
https://jira.jboss.org/jira/browse/JBESB-2741
Simplify "smooks_file_splitter_router" quickstart

Modified: labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/build.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/build.xml	2009-07-14 07:08:58 UTC (rev 27990)
+++ labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/build.xml	2009-07-14 07:43:58 UTC (rev 27991)
@@ -33,7 +33,7 @@
 		<move file="${order.xml}" todir="${jbossesb.inputdir}"/>
 
 	</target>  
-	
+
 	<target name="config">
 			<delete dir="${jbossesb.rootdir}" quiet="true"/>
 			<mkdir dir="${jbossesb.rootdir}"/>
@@ -51,10 +51,6 @@
 					<filter token="INPUTDIR" value="${jbossesb.inputdir}"/>
 					<filter token="OUTPUTDIR" value="${jbossesb.outputdir}"/>
 					<filter token="ERRORDIR" value="${jbossesb.errordir}"/>
-                    <filter token="FTP_HOSTNAME" value="${quickstart.jbossesb.ftp.hostname}"/>
-                    <filter token="FTP_USERNAME" value="${quickstart.jbossesb.ftp.username}"/>
-                    <filter token="FTP_PASSWORD" value="${quickstart.jbossesb.ftp.password}"/>
-                    <filter token="FTP_DIRECTORY" value="${quickstart.jbossesb.ftp.directory}"/>
 			</filterset>
 		</copy>
 	</target>

Modified: labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/jboss-esb-unfiltered.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/jboss-esb-unfiltered.xml	2009-07-14 07:08:58 UTC (rev 27990)
+++ labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/jboss-esb-unfiltered.xml	2009-07-14 07:43:58 UTC (rev 27991)
@@ -1,114 +1,62 @@
 <?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" parameterReloadSecs="5" >
+<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.1.0.xsd"
+          parameterReloadSecs="5">
 
     <providers>
-          <fs-provider name="FSprovider1">
-          	<fs-bus busid="smooksFileChannel">
-          		<fs-message-filter
-          			directory="@INPUTDIR@"
-          			input-suffix=".xml"
-          			work-suffix=".esbWorking"
-          			post-delete="false"
-          			post-rename="false"
-          			post-directory="@OUTPUTDIR@"
-          			post-suffix=".sentToEsb"
-          			error-delete="false"
-          			error-directory="@ERRORDIR@"
-          			error-suffix=".IN_ERROR"
-          		/>
-          	</fs-bus>
-          </fs-provider>
-          
-          <jms-provider name="JBossMessaging" connection-factory="ConnectionFactory"> 
-			    <jms-bus busid="quickstartEsbChannel">
-			        <jms-message-filter dest-type="QUEUE" dest-name="queue/quickstart_smooks_file_splitter_router_esb"/>
-			    </jms-bus>
-			
-		   </jms-provider>
+        <fs-provider name="FSprovider1">
+            <fs-bus busid="smooksFileChannel">
+                <fs-message-filter
+                        directory="@INPUTDIR@"
+                        input-suffix=".xml"
+                        work-suffix=".esbWorking"
+                        post-delete="true"
+                        post-directory="@OUTPUTDIR@"
+                        post-suffix=".sentToEsb"
+                        error-delete="false"
+                        error-directory="@ERRORDIR@"
+                        error-suffix=".IN_ERROR"
+                        />
+            </fs-bus>
+        </fs-provider>
 
-      </providers>
-      
-      <services>
-          
-        <service 
-			category="smooksFileSplitterRouter"
-			name="service"
-        	description="Smooks Quickstart File Router Splitter" >
+    </providers>
+
+    <services>
+
+        <!--
+            Splitter Service...
+        -->
+        <service category="QS" name="Splitter" description="Splitter Service" invmScope="GLOBAL">
             <listeners>
-            	<fs-listener name="FileGateway"
-            		busidref="smooksFileChannel"
-            		is-gateway="true"
-					schedule-frequency="10">
-					<property name="composer-class" value="org.jboss.soa.esb.listeners.gateway.LocalFileNameMessageComposer"/>
-				</fs-listener>
-                <jms-listener name="helloWorldFileAction" busidref="quickstartEsbChannel"/>
+                <!-- Splitting the message at the gateway via the FileStreamSplitter composer class allows us to
+                     handle huge messages... -->
+                <fs-listener name="FileGateway" busidref="smooksFileChannel" is-gateway="true" schedule-frequency="2">
+                    <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"/ -->
+                </fs-listener>
             </listeners>
-            <actions mep="OneWay">       
+            <actions mep="OneWay">
+                <action name="print" class="org.jboss.soa.esb.actions.SystemPrintln">
+                    <property name="message" value="[Splitter] Message Split complete"/>
+                </action>
 
-                    <action name="logBodyOnEntry" class="org.jboss.soa.esb.actions.LogAction">
-                   		<property name="logger"		value="SmooksQuickstart"/>
-                   		<property name="logLevel"	value="info"/>
-                   		<property name="message"	value="Body upon entering :"/>
-                   		<property name="logBody"	value="true"/>
-                    </action>
+                <!-- The next action is for Continuous Integration testing -->
+                <action name="testStore" class="org.jboss.soa.esb.actions.TestMessageStore"/>
+            </actions>
+        </service>
 
-					<action name="fileToStream" class="org.jboss.soa.esb.sample.quickstart.smooksfilesplitterrouter.actions.FileToStream"/>
-
-					<action name="createSourceResult" class="org.jboss.soa.esb.actions.converters.StreamToSourceResult"/>
-
-					<action name="startTime" class="org.jboss.soa.esb.sample.quickstart.smooksfilesplitterrouter.actions.DisplayTimeAction">
-                   		<property name="logger"		value="SmooksQuickstart"/>
-                   		<property name="logLevel"	value="info"/>
-                   		<property name="format"		value="HH:mm:ss"/>
-					</action>
-
-					<action name="memUsageBefore" class="org.jboss.soa.esb.sample.quickstart.smooksfilesplitterrouter.actions.DisplayMemoryUsageAction">
-                   		<property name="logger"		value="SmooksQuickstart"/>
-                   		<property name="logLevel"	value="info"/>
-					</action>
-
-					<action name="transform" class="org.jboss.soa.esb.smooks.SmooksAction">
-						<property name="smooksConfig" value="smooks-config.xml" />
-                    </action>
-
-					<action name="getFileList" class="org.jboss.soa.esb.sample.quickstart.smooksfilesplitterrouter.GetFileListFromExecutionContext"/>
-
-                    <action name="logBodyAfterTransform" class="org.jboss.soa.esb.actions.LogAction">
-                   		<property name="logger"		value="SmooksQuickstart"/>
-                   		<property name="logLevel"	value="info"/>
-                   		<property name="message"	value="Body after transform :"/>
-                   		<property name="logBody"	value="true"/>
-					</action>
-
-					<action name="endTime" class="org.jboss.soa.esb.sample.quickstart.smooksfilesplitterrouter.actions.DisplayTimeAction">
-                   		<property name="logger"		value="SmooksQuickstart"/>
-                   		<property name="logLevel"	value="info"/>
-                   		<property name="format"		value="HH:mm:ss"/>
-					</action>
-
-					<action name="memUsageAfter" class="org.jboss.soa.esb.sample.quickstart.smooksfilesplitterrouter.actions.DisplayMemoryUsageAction">
-                   		<property name="logger"		value="SmooksQuickstart"/>
-                   		<property name="logLevel"	value="info"/>
-					</action>
-
-					<action name="notificationAction" class="org.jboss.soa.esb.actions.Notifier">
-						<property name="okMethod" value="notifyOK" />
-						<property name="notification-details">
-							<NotificationList type="ok">
-								<target class="NotifyFTPList">
-									<ftp URL="ftp://@FTP_USERNAME@:@FTP_PASSWORD@@@FTP_HOSTNAME@/@FTP_DIRECTORY@" 
-										filename="{org.jboss.soa.esb.gateway.file}"
-										listFiles="true"
-										deleteListFile="true"/>
-								</target>
-							</NotificationList>
-						</property>
-					</action>
-
-					<!-- The next action is for Continuous Integration testing -->
-                   	<action name="testStore" class="org.jboss.soa.esb.actions.TestMessageStore" />
+        <!--
+            Receiver Service...
+        -->
+        <service category="QS" name="Receiver" description="Receiver Service" invmScope="GLOBAL">
+            <actions mep="OneWay">
+                <action name="print" class="org.jboss.soa.esb.actions.SystemPrintln">
+                    <property name="message" value="[Receiver] Message Fragment Received"/>
+                </action>
             </actions>
         </service>
-      </services>
-     
+
+    </services>
+
 </jbossesb>

Modified: labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/orderitem-split.ftl
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/orderitem-split.ftl	2009-07-14 07:08:58 UTC (rev 27990)
+++ labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/orderitem-split.ftl	2009-07-14 07:43:58 UTC (rev 27991)
@@ -1,7 +1,7 @@
-<orderitem id="${orderItem.itemId}" order="${order.orderId}">
+<orderitem id="${orderItem.itemId}" order="${header.orderId}">
     <customer>
-        <name>${order.customerName}</name>
-        <number>${order.customerNumber}</number>
+        <name>${header.customerName}</name>
+        <number>${header.customerNumber}</number>
     </customer>
     <details>
         <productId>${orderItem.productId}</productId>

Modified: labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/readme.txt
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/readme.txt	2009-07-14 07:08:58 UTC (rev 27990)
+++ labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/readme.txt	2009-07-14 07:43:58 UTC (rev 27991)
@@ -1,21 +1,29 @@
 Overview:
 =========
  This quickstart demonstrates JBossESB ability to process large files.
- A large file is picked up by a file gateway, transformed, and sent to an FTP server.
 
- The file being process will never exist in the ESB Message object, instead the body
- will only contain the name of the file that is being processed. Note, that this
- means a Network File System (NFS) must be in place if you have multiple ESB instances
- deployed on separate machines.
+ The quickstart works as follows:
+ 1.  There are 2 Services:
+     a) Splitter Service
+     b) Receiver Service
+ 2.  The Splitter Service picks up an XML order message via the File Gateway (<fs-listener>).
+     The <fs-listener> is configured with the FileStreamSplitter, which applies a Smooks
+     message splitting process (defined in smooks-config.xml).  This process splits the
+     XML message, routing XML message fragments to the Receiver Service.
+ 3.  The Smooks splitting process works by streaming the XML message and while doing so:
+     a) Extracts data from the order header details and places it in a "header" bean.
+     b) Extracts data from the order item and places it in a "orderItem" bean.  It only
+        ever has the details of a single order item in memory at any given time.  This
+        is what allows it to process a huge message stream.
+     c) As it passes each order item, applys a FreeMarker template to the data in the bean
+        context ("header" and "orderItem) to generate the split fragment for the order item.
+     d) As it passes each order item, routes the generated split fragment for that order item,
+        as generated by the FreeMarker template, to the Receiver Service.
 
- The quickstart also demonstrates one of the features of Smooks v1.0, which is the 
- 'routing' transformed output to a file. For more information about the different 
- routing features available take a look here:
- http://milyn.codehaus.org/Smooks+User+Guide#SmooksUserGuide-MessageSplitting%26Routing
+Note here that the split fragments being generated and routed to the Receiver Service are not
+just dumb block copies of fragments from the source message.  They are formatted differently
+and contain data not just from the individual order item, but also from the order header.
 
- This example intentionally only creates one file to be created using a Smooks
- condition. This was done to limit the number of files that get created. 
-
 Running this quickstart:
 ========================
   Please refer to 'ant help-quickstarts' for prerequisites about the quickstarts
@@ -30,65 +38,10 @@
 ===========================
   1. 'ant deploy'
   2. 'ant runtest' 	- you will be asked how many order-items that the sample SampleOrder.xml should contain.
-  3. Switch to the Application Server console to see the output from the ESB
+  3. Switch to the Application Server console to see the output from the ESB.  Here you will see
+     each of the split message fragments as received by the "Receiver" service.
   4. In this folder ("Window1"), type 'ant undeploy'.
 
-Monitoring (optional)
-===========================
-  1. Add the following variable to JAVA_OPTS in run.conf:
-	 '-Dcom.sun.management.jmxremote'
-	 and restart the ESB server.
-  2. start the jconsole application: 
-	 jconsole &
-  3. run the quickstart with different file sizes to see how that effects memory usage
-
-What to look at in this Quickstart:
-===================================
-
- Example ESB server console output:
-
-	INFO  [SmooksQuickstart] Body :/opt/jboss/esb/source/trunk2/product/samples/quickstarts/smooks_file_splitter_router/build/dirs/input/SampleOrder.xml.esbWorking
-	INFO  [SmooksQuickstart] 08:39:36
-	INFO  [SmooksQuickstart] Max mem [518464], Allocated mem [129856], Free mem [64183], Total Free mem [452791]
-	INFO  [SmooksQuickstart] Body :[/tmp/OrderFiles.lst]
-	INFO  [SmooksQuickstart] 08:39:47
-	INFO  [SmooksQuickstart] Max mem [518464], Allocated mem [129856], Free mem [65651], Total Free mem [454259]
-	INFO  [NotifyFTPList] Sending from listFile [/tmp/OrderFiles.lst]
-	INFO  [NotifyFTPList] Done sending from listFile [/tmp/OrderFiles.lst]
-
- Description of output:
-	* The first log,'Body' displays that the file name is located in the message object, and not the file contents.
-	* Next log displays the time before the transformation which is useful for larger files
-	* Next log displays the memory usage before the transformation. (See also the 'Monitoring' section in this file)
-	* Next log displays what the body looks like after the transformation
-	* Next are again the time and memory usage log statements
-	* Next NotifyFTPList displays that it is sending the files listed in '/tmp/OrderFiles.lst' to the FTP server.
-
- jboss-esb-unfiltered.xml
-	* Notice that the fs-message-filter is configured with 'post-rename' set to false:
-		<fs-message-filter
-			...
-			 post-rename="false"
-			...
-		</fs-message-filter>
-		This is done to avoid copying the file locally.
-
-	* Notice that the fs-listener is configured with a message composer:
-		<property name="composer-class" value="org.jboss.soa.esb.listeners.gateway.LocalFileNameMessageComposer"/>
-		This composer will return the path to the file instead of the files content
-
-	* fileToStream action:
-		This action will return an input stream for the file located in the message object
-
-	* createSourceResult:
-		This action will create a Smooks SourceResult object in preperation for the SmooksTransform
-
-	* notificationAction:
-		Notice that the class for target is 'NotifyFTPList'. 
-		NotifyFTPList extends NotifyFTP and adds the ability to send a single file name or list of file names located 
-		in the ESB Message object.
-
-
  File sizes:
 	When generating the SampleOrder.xml the following nr of order-items can be entered(
 	really any number can be entered but this is to give an idea of the how many rows 

Modified: labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/smooks-config.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/smooks-config.xml	2009-07-14 07:08:58 UTC (rev 27990)
+++ labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/smooks-config.xml	2009-07-14 07:43:58 UTC (rev 27991)
@@ -2,18 +2,19 @@
 <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
                       xmlns:jb="http://www.milyn.org/xsd/smooks/javabean-1.2.xsd"
                       xmlns:ftl="http://www.milyn.org/xsd/smooks/freemarker-1.1.xsd"
-                      xmlns:file="http://www.milyn.org/xsd/smooks/file-routing-1.1.xsd">
+                      xmlns:esbr="http://www.jboss.org/xsd/jbossesb/smooks/routing-1.0.xsd">
 
     <params>        
         <param name="stream.filter.type">SAX</param>
     </params>
 
     <conditions>
-        <condition id="routeItem"><!-- orderItem.itemId > 70 --></condition>
+        <!-- route the even numbered order items -->
+        <condition id="routeItem"><!-- orderItem.itemId % 2 == 0 --></condition>
     </conditions>
 
     <!-- Capture some data from the message into the bean context... -->
-    <jb:bean beanId="order" class="java.util.Hashtable" createOnElement="order">
+    <jb:bean beanId="header" class="java.util.Hashtable" createOnElement="order">
         <jb:value property="orderId" data="order/@id"/>
         <jb:value property="customerNumber" data="header/customer/@number"/>
         <jb:value property="customerName" data="header/customer"/>
@@ -26,23 +27,19 @@
     </jb:bean>
 
     <!-- On each order-item, apply a template to the data captured into the bean context,
-         outputting the templating result to the file stream specified below... -->
+         binding the templating result back into the bean context under the
+         beanId "orderItemFragment" to be routed by the following ESB Router... -->
     <ftl:freemarker applyOnElement="order-item">
         <condition idRef="routeItem" />
-        <ftl:template>orderitem-split.ftl</ftl:template>
+        <ftl:template>/orderitem-split.ftl</ftl:template>
         <ftl:use>
-            <ftl:outputTo outputStreamResource="orderItemSplitStream" />
+            <ftl:bindTo id="orderItemFragment" />
         </ftl:use>
     </ftl:freemarker>
 
-    <!-- For each order-item, open a file output stream.  Used in the templating
-         operations defined above. -->
-    <file:outputStream openOnElement="order-item" resourceName="orderItemSplitStream">
+    <!-- On each order-item, route the "orderItemFragment" bean to the  -->
+    <esbr:routeBean beanIdRef="orderItemFragment" toServiceCategory="QS" toServiceName="Receiver" routeOnElement="order-item">
         <condition idRef="routeItem" />
-        <file:fileNamePattern>order-${order.orderId}-${orderItem.itemId}.xml</file:fileNamePattern>
-        <file:destinationDirectoryPattern>/tmp</file:destinationDirectoryPattern>
-        <file:listFileNamePattern>order-${order.orderId}.lst</file:listFileNamePattern>
-        <file:highWaterMark mark="10" />
-    </file:outputStream>
+    </esbr:routeBean>
 
 </smooks-resource-list>

Deleted: labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/src/org/jboss/soa/esb/sample/quickstart/smooksfilesplitterrouter/GetFileListFromExecutionContext.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/src/org/jboss/soa/esb/sample/quickstart/smooksfilesplitterrouter/GetFileListFromExecutionContext.java	2009-07-14 07:08:58 UTC (rev 27990)
+++ labs/jbossesb/trunk/product/samples/quickstarts/smooks_file_splitter_router/src/org/jboss/soa/esb/sample/quickstart/smooksfilesplitterrouter/GetFileListFromExecutionContext.java	2009-07-14 07:43:58 UTC (rev 27991)
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source Copyright 2006, JBoss Inc., and
- * individual contributors as indicated by the @authors tag. See the
- * copyright.txt in the distribution for a full listing of individual
- * contributors.
- * 
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- * 
- * This software is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- * 
- * You should have received a copy of the GNU Lesser General Public License
- * along with this software; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
- * site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.sample.quickstart.smooksfilesplitterrouter;
-
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.soa.esb.actions.BeanConfiguredAction;
-import org.jboss.soa.esb.message.Message;
-import org.milyn.container.ExecutionContext;
-import org.milyn.routing.file.FileListAccessor;
-
-/**
- * 
- * @author <a href="mailto:daniel.bevenius at gmail.com">Daniel Bevenius</a>			
- *
- */
-public class GetFileListFromExecutionContext implements BeanConfiguredAction
-{
-	public Message process( final Message message )
-	{
-		Object object = message.getBody().get("SmooksExecutionContext");
-		if ( object != null )
-		{
-    		List<String> listFileNames = FileListAccessor.getListFileNames( (Map) object );
-    		message.getBody().add( listFileNames );
-		}
-		return message;
-	}
-
-}
\ No newline at end of file




More information about the jboss-svn-commits mailing list