Smooks problem
tagnegilles Jan 21, 2010 7:28 PMHi Guys,
I try to use smooks in my ESB project to store some data in an exterm database. But it doesn't work. I am doing may be something wrong. Please i need your help. I am using JBossESB 4.7 in JBoss AS 5.1.0 jdk6
jboss-esb.xml
<?xml version="1.0"?> <jbossesb parameterReloadSecs="5" xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.2.0.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.2.0.xsd http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.2.0.xsd"> <providers> <jms-provider connection-factory="ConnectionFactory" name="JbossMessaging"> <jms-bus busid="splitterChannel"> <jms-message-filter dest-name="/queue/splitterQueue" dest-type="QUEUE"/> </jms-bus> </jms-provider> <schedule-provider name="CronSchedulerProvider"> <cron-schedule cronExpression="0/3 * * * * ?" scheduleid="myCronSchedule"/> </schedule-provider> <fs-provider name="FileSystemProvider"> <fs-bus busid="esbFileSystem"> <fs-message-filter directory="/Users/gilles/Desktop/ESB/Input" error-delete="false" error-directory="/Users/gilles/Desktop/ESB/Error" error-suffix=".error" input-suffix=".csv" post-delete="true" post-directory="/Users/gilles/Desktop/ESB/Post" post-suffix=".post" work-suffix=".work"/> </fs-bus> </fs-provider> </providers> <services> <service category="splitterTest" description="Splitt the .csv file" invmScope="GLOBAL" name="fileSplitter"> <listeners> <fs-listener busidref="esbFileSystem" is-gateway="true" name="FileListener" scheduleidref="myCronSchedule"> <property name="composer-class" value="org.jboss.soa.esb.smooks.splitting.FileStreamSplitter"/> <property name="splitterConfig" value="/mySmooksConf.xml"/> </fs-listener> </listeners> <actions mep="OneWay"> <action class="org.jboss.soa.esb.actions.SystemPrintln" name="Print"> <property name="message" value="[Splitter] Message Split complete"/> </action> </actions> </service> <service category="splitterTest" description="Route the message to a jms queue" invmScope="GLOBAL" name="routerSplitter"> <actions mep="OneWay"> <action class="org.jboss.soa.esb.actions.Notifier" name="NotifyAction1"> <property name="destinations"> <NotificationList type="ok"> <target class="NotifyQueues"> <queue jndiName="queue/splitterQueue"/> </target> </NotificationList> </property> <property name="okMethod" value="notifyOK"/> </action> <!-- Alte Version <action class="org.jboss.soa.esb.actions.routing.JMSRouter" name="jmsRouter"> <property name="unwrap" value="true"/> <property name="jndiName" value="queue/splitterQueue"/> </action> --> </actions> </service> <service category="splitterTest" description="Route the age element of the message to a jms queue" invmScope="GLOBAL" name="routerAgeSplitter"> <actions mep="OneWay"> <action class="org.jboss.soa.esb.actions.Notifier" name="NotifyAction2"> <property name="destinations"> <NotificationList type="ok"> <target class="NotifyQueues"> <queue jndiName="queue/splitterAgeESBQueue"/> </target> </NotificationList> </property> <property name="okMethod" value="notifyOK"/> </action> <!-- <action class="org.jboss.soa.esb.actions.routing.JMSRouter" name="jmsRouterAge"> <property name="unwrap" value="true"/> <property name="jndiName" value="queue/splitterAgeESBQueue"/> </action> --> </actions> </service> <service category="splitterTest" description="Make routing on Age" invmScope="GLOBAL" name="recipientListAge"> <actions mep="OneWay"> <action class="org.jboss.soa.esb.actions.StaticRouter" name="staticRoutingAge"> <property name="destinations"> <route-to destination-name="ToRouterAgeSplitter" service-category="splitterTest" service-name="routerAgeSplitter"/> <route-to destination-name="ToDbPersistAge" service-category="splitterTest" service-name="dbPersist"/> </property> </action> </actions> </service> <service category="splitterTest" description="Persist data in the database" invmScope="GLOBAL" name="dbPersist"> <actions mep="OneWay"> <action class="org.jboss.soa.esb.actions.SystemPrintln" name="PrintMessage1"> <property name="message" value="Message"/> </action> <action class="org.jboss.soa.esb.smooks.SmooksAction" name="smoksActionXML"> <property name="smooksConfig" value="/xmlSmooksConf.xml"/> </action> <action class="org.jboss.soa.esb.actions.SystemPrintln" name="PrintMessage2"> <property name="message" value="Message"/> </action> <action class="org.jboss.soa.esb.smooks.SmooksAction" name="smoksActionDB"> <property name="smooksConfig" value="/dbSmooksConf.xml"/> </action> </actions> </service> </services> </jbossesb>
mySmooksConf.xml
<?xml version="1.0" encoding="UTF-8"?> <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:esbr="http://www.jboss.org/xsd/jbossesb/smooks/routing-1.0.xsd" xmlns:csv="http://www.milyn.org/xsd/smooks/csv-1.2.xsd"> <params> <param name="stream.filter.type">SAX</param> </params> <csv:reader fields="id,firstname,lastname,age" rootElementName="liste" recordElementName="person"> <csv:singleBinding beanId="personvirtual" class="java.util.HashMap"/> </csv:reader> <ftl:freemarker applyOnElement="person"> <ftl:template><!--${personvirtual.id},${personvirtual.firstname},${personvirtual.lastname}--></ftl:template> <ftl:use> <ftl:bindTo id="personFragment" /> </ftl:use> </ftl:freemarker> <ftl:freemarker applyOnElement="person"> <ftl:template><!--${personvirtual.id},${personvirtual.age}--></ftl:template> <ftl:use> <ftl:bindTo id="personAgeFragment" /> </ftl:use> </ftl:freemarker> <esbr:routeBean beanIdRef="personFragment" toServiceCategory="splitterTest" toServiceName="routerSplitter" routeOnElement="person"/> <esbr:routeBean beanIdRef="personAgeFragment" toServiceCategory="splitterTest" toServiceName="recipientListAge" routeOnElement="person"/> </smooks-resource-list>
xmlSmooksConf.xml
<?xml version="1.0" encoding="UTF-8"?> <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd" xmlns:csv="http://www.milyn.org/xsd/smooks/csv-1.2.xsd"> <params> <param name="stream.filter.type">SAX</param> </params> <csv:reader fields="id,age" rootElementName="personliste" recordElementName="person"/> </smooks-resource-list>