|
Page Edited :
SM :
servicemix-file
servicemix-file has been edited by Gert Vanthienen (Jun 22, 2008). Content:ServiceMix FileThe ServiceMix File component provides JBI integration to the file system. It can be used to read & write files via URI or to periodically poll directories for new files. Note that this component is only available in releases >= 3.1. URIYou can use the familiar file URI to communicate with files file:foo.xml
file://path/to/something
For all xbean file endpoint configuration take a look at Xml schemas FilteringFiltering of files to use during the polling process can be accomplished by configuring the filter property. Filter example <file:poller service="test:poller" endpoint="poller" file="file:inbox" targetService="test:service" targetEndpoint="endpoint" period="10000" recursive="true"> <property name="filter"> <bean class="org.apache.oro.io.GlobFilenameFilter"> <constructor-arg value="*.xml" /> </bean> </property> </file:poller> In the example above, the Apache ORO jar must be in the classpath. See: http://jakarta.apache.org/oro/ ServiceMix 3.2 Filter example <file:poller service="test:poller" endpoint="poller" file="file:inbox" targetService="test:service" targetEndpoint="endpoint" period="10000" recursive="true"> <property name="filter"> <bean class="org.apache.commons.io.filefilter.WildcardFilter"> <constructor-arg value="*.csv" /> </bean> </property> </file:poller> In the example above it uses Apache Commons IO WildcardFilter as it implements FileFilter. The Apache Commons IO jar file must be in the classpath. See: http://commons.apache.org/io/ MarshalersBy default, poller endpoints expect the content of the file to be in xml format. Marshaler example <file:sender service="test:service" endpoint="endpoint" directory="file:target/componentOutput"> <file:marshaler> <sm:defaultFileMarshaler> <sm:fileName> <!-- lets use a header from the message --> <sm:xpathString xpath="concat($name, '.xml')"/> </sm:fileName> </sm:defaultFileMarshaler> </file:marshaler> </file:sender> Below is an example of a non-XML file marshaler that moves a file from an inbox to an outbox directory. The binary marshaler sends a message with the file attached. This allows any file to be processed. The contents below were used in an xbean.xml file for a service unit named filemover Binary File Marshaler example <?xml version="1.0"?> <beans xmlns:f="http://servicemix.apache.org/file/1.0" xmlns:proj="http://servicemix.apache.org/samples/filemover" xmlns:sm="http://servicemix.apache.org/config/1.0"> <f:sender service="proj:fileSender" endpoint="endpoint" directory="file:///C:/opensrc/test/myOutbox" autoCreateDirectory="true"> <property name="marshaler"> <bean class="org.apache.servicemix.components.util.BinaryFileMarshaler" /> </property> </f:sender> <f:poller service="proj:filePoller" endpoint="poller" file="file:///C:/opensrc/test/myInbox" targetService="proj:fileSender" targetEndpoint="endpoint" period="60000" recursive="true" autoCreateDirectory="true"> <property name="marshaler"> <bean class="org.apache.servicemix.components.util.BinaryFileMarshaler" /> </property> </f:poller> </beans> |
Unsubscribe or edit your notifications preferences
