Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

The ServiceMix VFS component provides support for reading from and writing to virtual file systems via the enterprise service bus by using the Apache commons-vfs library.

Note
titleAvailability

Note that this component is only available in releases >= 3.3.

Maven Archetype

Two archetypes are provided.

You can use Maven servicemix-vfs-poller-service-unit creates archetype to create a VFS poller SUservice unit:

Code Block
mvn archetype:create \
  -DarchetypeGroupId=org.apache.servicemix.tooling \
  -DarchetypeArtifactId=servicemix-vfs-poller-service-unit \
  -DarchetypeVersion=2010.01 \
  -DgroupId=your.group.id \
  -DartifactId=your.artifact.id \
  -Dversion=your-version

servicemix-vfs-sender-service-unit creates a VFS sender Once you've customized the service unit, simply install the SU:

Code Block
mvn archetype:create \
  -DarchetypeGroupId=org.apache.servicemix.tooling \
  -DarchetypeArtifactId=servicemix-vfs-sender-service-unit \
  -DarchetypeVersion=2010.01 \
  -DgroupId=your.group.id \
  -DartifactId=your.artifact.id \
  -Dversion=your-version

Endpoints

install
Info

Remember that to be deployable in ServiceMix, the ServiceUnit has to be embedded in a Service Assembly: only the Service Assembly zip file can be deployed in ServiceMix.
To add your SU in a SA, you need to define it in the dependency sets:

Code Block

<dependency>
  <groupId>your.group.id</groupId>
  <artifactId>your.artifact.id</artifactId>
  <version>your-version</version>
</dependency>

Endpoints Configuration

Poller Endpoint

The VFS Poller endpoint polls a VFS path, read the VFS file using the marshaler and send the file content to the NMR.

Info

The VFS Poller endpoint generates an InOnly exchange.

Code Block
langxml
titlePolling endpointVFS Poller Endpoint
<vfs:poller service="testreplaceMe:vfsPollerserviceName"
            endpoint="pollerEndpointvfs-poller"
            path="file:///homevfs/lheinpath/input/"
            targetService="testreplaceMe:vfsSenderserviceName"
            periodtargetEndpoint="10000target-endpoint"
            deleteFileperiod="true10000" 
            recursivedeleteFile="true" >

   <property name="marshaler">
      <bean class="org.apache.servicemix.components.util.BinaryFileMarshaler" />
   </property>

</vfs:poller>
Code Block
langxml
titleSender endpoint

<vfs:sender  service="test:vfsSender"
             endpoint="senderEndpoint"
             path="file:///home/lhein/output/" recursive="true" >

   <property name="marshaler">
      <bean class="org.apache.servicemix.components.util.BinaryFileMarshaler" />
   </property>
    
</vfs:sender>

...

poller>
Info
titleVFS Poller endpoint attributesEndpoint Attributes
borderStylesolidbgColor='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

comparator

class

implementation of java.util.Comparator to order file process

null - no comparator

fileSystemManager

class

sets the vfs file system manager object

null (using VFS.getManager() )

...

Sender Endpoint

The VFS Sender endpoint expects messages coming from the NMR, converts it using the marshaler and send it to the VFS path.

Code Block
langxml
titleVFS Sender Endpoint

<vfs:sender  service="replaceMe:serviceName"
             endpoint="vfs-sender"
             path="file:///vfs/path/output/">

   <property name="marshaler">
      <bean class="org.apache.servicemix.components.util.BinaryFileMarshaler" />
   </property>
    
</vfs:sender>
Info
titleVFS Sender endpoint attributesEndpoint Attributes
borderStylesolidbgColor='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() )

...

Marshalers

By default, poller endpoints expect the content of the file to be in xml 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.

...