ServiceMix VFS
The ServiceMix VFS component provides support for readin from and writing to virtual file systems via the enterprise service bus by using the Apache commons-vfs library.
Note |
---|
|
Note that this component is only available in releases >= 3.3. |
Endpoints
Code Block |
---|
lang | xml |
---|
title | Polling endpoint |
---|
|
<vfs:poller service="test:vfsPoller"
endpoint="pollerEndpoint"
path="file:///home/lhein/input/"
targetService="test:vfsSender"
period="10000"
deleteFile="true"
recursive="true" >
<property name="marshaler">
<bean class="org.apache.servicemix.components.util.BinaryFileMarshaler" />
</property>
</vfs:poller>
|
Code Block |
---|
lang | xml |
---|
title | Sender endpoint |
---|
|
<vfs:sender service="test:vfsSender"
endpoint="senderEndpoint"
path="file:///home/lhein/output/">
<property name="marshaler">
<bean class="org.apache.servicemix.components.util.BinaryFileMarshaler" />
</property>
</vfs:sender>
|
Poller generates an InOnly message
Info |
---|
title | Poller endpoint attributes |
---|
borderStyle | solidbgColor='lighblue' |
---|
|
Name | Type | Description | Default |
---|
service | QName | the service name of the endpoint | required to be spec'd | endpoint | string | the endpoint name of the endpoint | required to be spec'd | interfaceName | QName | the interface name of the endpoint | | targetService | QName | the service name of the target endpoint | | targetEndPoint | string | the endpoint name of the target endpoint | | targetInterface | QName | the interface name of the target endpoint | | targetUri | string | the uri of the target endpoint | | firstTime | date | datetime before first poll can take place | null (first poll right after start) | delay | long | amount of time first polling is delayed after start | 0 | period | long | amount of time between polls | 5000 | path | string | sets the vfs path to poll | null (must be spec'd) | deleteFile | boolean | delete file when it is processed | true | recursive | boolean | process sub directories | true | marshaler | class | org.apache.servicemix.components.util.FileMarshaler | DefaultFileMarshaler | lockManager | class | org.apache.servicemix.locks.LockManager | SimpleLockManager | selector | class | import org.apache.commons.vfs.FileSelector | null - no selector | fileSystemManager | class | sets the vfs file system manager object | null (using VFS.getManager() ) |
|
Info |
---|
title | Sender endpoint attributes |
---|
borderStyle | solidbgColor='lighblue' |
---|
|
Name | Type | Description | Default |
---|
service | QName | the service name of the endpoint | required to be spec'd | endpoint | string | the endpoint name of the endpoint | required to be spec'd | path | string | sets the vfs path to poll | null (must be spec'd) | marshaler | class | org.apache.servicemix.components.util.FileMarshaler | DefaultFileMarshaler | fileSystemManager | class | sets the vfs file system manager object | null (using VFS.getManager() ) |
|
For all xbean file endpoint configuration take a look at Xml schemas
Marshalers
By default, poller endpoints expect the content of the file to be in xml format.
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
Code Block |
---|
lang | xml |
---|
title | Binary File Marshaler example |
---|
|
<?xml version="1.0"?>
<beans xmlns:vfs="http://servicemix.apache.org/vfs/1.0"
xmlns:proj="http://servicemix.apache.org/samples/filemover"
xmlns:sm="http://servicemix.apache.org/config/1.0">
<vfs:poller service="proj:vfsPoller"
endpoint="pollerEndpoint"
path="file:///C:/opensrc/test/myInbox"
targetService="proj:vfsSender"
period="10000"
deleteFile="true"
recursive="true" >
<property name="marshaler">
<bean class="org.apache.servicemix.components.util.BinaryFileMarshaler" />
</property>
</vfs:poller>
|
Code Block |
---|
lang | xml |
---|
title | Sender endpoint |
---|
|
<vfs:sender service="proj:vfsSender"
endpoint="senderEndpoint"
path="file:///C:/opensrc/test/myOutbox/">
<property name="marshaler">
<bean class="org.apache.servicemix.components.util.BinaryFileMarshaler" />
</property>
</vfs:sender>
</beans>
|
The path attribute
Have a look at the Apache Commons Supported File Systems page.TODO