Reputation: 73
I have been working with smooks to try and process semi large XML files (170MB - 250MB). I managed to get it working and I can get it to process some of the elements in my XML fairly quickly.
I believe I am running into an issue where the output file name that I am setting in the <file:fileNamePattern>
element is not unique enough.
Is there anyway for me to create a unique file name from within the smooks configuration via a file number increment (based on number of files currently in directory), time stamp or a random generated messageId?
Any help is greatly appreciated. I posted the error I am receiving and the smooks configuration that I have been testing with below.
Smooks Configuration
<?xml version="1.0" encoding="UTF-8"?>
<smooks-resource-list xmlns:core="http://www.milyn.org/xsd/smooks/smooks-core-1.3.xsd"
xmlns:ftl="http://www.milyn.org/xsd/smooks/freemarker-1.1.xsd"
xmlns:jb="http://www.milyn.org/xsd/smooks/javabean-1.2.xsd"
xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
xmlns:file="http://www.milyn.org/xsd/smooks/file-routing-1.1.xsd">
<core:filterSettings defaultSerialization="false" type="SAX" />
<!-- Extract and decode data from the message. Later Used in the freemarker template.
Note that we could also use a NodeModel here... -->
<jb:bean beanId="row" class="java.util.Hashtable" createOnElement="row">
<jb:value data="row/@iBookID" decoder="Integer" property="iBookID"></jb:value>
<jb:value data="row/@vchEAN" decoder="String" property="vchEAN"></jb:value>
<jb:value data="row/@vchISBN" decoder="String" property="vchISBN"></jb:value>
</jb:bean>
<jb:bean beanId="myDate" createOnElement="row"/>
</jb:bean>
<ftl:freemarker applyOnElement="row">
<ftl:template><!--<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<p:insert_Levels_AR_ISBN_operation>
<p:iBookID xmlns:xs="http://ws.wso2.org/dataservice">${row.iBookID}</p:iBookID>
<p:vchEAN xmlns:xs="http://ws.wso2.org/dataservice">${row.vchEAN}</p:vchEAN>
</p:insert_Levels_AR_ISBN_operation>
</soapenv:Body>
</soapenv:Envelope>--></ftl:template>
<ftl:use>
<!-- Output the templating result to the "rowSplitStream" file output stream... -->
<ftl:outputTo outputStreamResource="rowSplitStream"></ftl:outputTo>
</ftl:use>
</ftl:freemarker>
<!-- Create/open a file output stream. This is writen to by the freemarker template (above).. -->
<file:outputStream openOnElement="row" resourceName="rowSplitStream">
<file:fileNamePattern>isbn-${myDate?datetime}.xml</file:fileNamePattern>
<file:destinationDirectoryPattern>var/process/renaissance/smooks/tmprows</file:destinationDirectoryPattern>
<file:highWaterMark mark="10000000"></file:highWaterMark>
</file:outputStream>
</smooks-resource-list>
Error Message
Caused by: org.milyn.SmooksException: Could not rename [/opt/wso2esb-4.9.0/var/process/renaissance/smooks/tmprows/.d95ba4b8-aa71-44e6-8486-adb8c9ad4bdd2660246907791429571.working] to [/opt/wso2esb-4.9.0/var/process/renaissance/smooks/tmprows/isbn-102-9780394885124-0-394-88512-0.xml]. [/opt/wso2esb-4.9.0/var/process/renaissance/smooks/tmprows/isbn-102-9780394885124-0-394-88512-0.xml] already exists.
at org.milyn.routing.file.FileOutputStreamResource.renameWorkingFile(FileOutputStreamResource.java:308)
at org.milyn.routing.file.FileOutputStreamResource.closeResource(FileOutputStreamResource.java:284)
at org.milyn.io.AbstractOutputStreamResource.executeVisitLifecycleCleanup(AbstractOutputStreamResource.java:135)
at org.milyn.delivery.sax.SAXHandler.endElement(SAXHandler.java:245)
at org.milyn.delivery.SmooksContentHandler.endElement(SmooksContentHandler.java:83)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.milyn.delivery.sax.SAXParser.parse(SAXParser.java:70)
at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:75)
... 19 more
Upvotes: 0
Views: 424
Reputation: 21
I am having a similar issue - looks like upgrading to Smooks 1.4 is the answer... PUUID and PTIME on http://www.smooks.org/mediawiki/index.php?title=V1.4:Smooks_v1.4_User_Guide
But if anyone knows any different please let me know too :)
Upvotes: 1
Reputation: 5946
Perhaps could you use an other node, like row.@iBookID, from your input xml to compose your filename ?
Upvotes: 0