Versions Compared

Key

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

ServiceMix FTP

The ServiceMix FTP component provides JBI integration to the FTP servers. It can be used to read & write files over FTP or to periodically poll directories for new files.

Maven Archetype

The Maven servicemix-ftp-service-unit archetype creates a FTP Service Unit including poller and sender endpoints sample:

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

Once you've customized the service unit, simply install the SU:

Code Block
mvn 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>

Endpoint Configuration

FTP Poller Endpoint

FTP Poller endpoints can be used to poll a FTP server directory for files, download them, and send an InOnly JBI exchange to the configured JBI service.

The following snippet shows a minimal definition of a poller endpoint:

Code Block
langxml
<ftp:poller service="test:poller"
            endpoint="endpoint"
            targetService="test:receiver"
            uri="ftp://servicemix:rocks@localhost/smx/test" />
Info
titlePoller endpoint attributes
borderStylesolidbgColor='lighblue'

Name

Type

Description

Required

service

QName

the service name of the proxied endpoint

yes

endpoint

String

the endpoint name of the proxied endpoint

yes

interfaceName

QName

the interface name of the proxied endpoint

no

targetService

QName

the service name of the target endpoint

one of targetService, targetInterface or targetUri must be specified

targetEndpoint

String

the endpoint name of the target endpoint

one of targetService, targetInterface or targetUri must be specified

targetInterface

QName

the interface name of the target endpoint

one of targetService, targetInterface or targetUri must be specified

targetUri

String

the uri of the target endpoint

one of targetService, targetInterface or targetUri must be specified

uri

URI

the ftp uri to access the FTP server (see #URI)

yes

autoCreateDirectory

boolean

creates dir if doesn't exist
(available since 2009.01)

true

archive

URI

sets the directory uri to archive files before deleting them
(available since 2009.01)

null

deleteFile

boolean

whether the file should be deleted from the FTP server after processing

no (defaults to true)

stateless

boolean

whether the polled file should be sent asynchronous or synchronous to the nmr

no (defaults to true)

recursive

boolean

whether subdirectories should be polled

no (defaults to true)

filter

java.io.FileFilter

a filter used when polling files: files that do not match this filter will be ignored

no

marshaler

FileMarshaler

a marshaler can be used to customize how the file is read / written (see #Marshalers)

no

lockManager

o.a.s.locks.LockManager

a custom lock manager can be used to cluster poller endpoints or to keep track of processed files when the deleteFile attribute is set to false

no

clientPool

FTPClientPool

 

no

FTP Sender Endpoint

FTP Sender endpoints are used are provider endpoints (in the JBI sense) which accepts incoming InOnly exchanges and write the content of the exchange to a file on the FTP server.

Here is an example of a simple sender endpoint:

Code Block
langxml
<ftp:sender service="test:service"
            endpoint="endpoint" 
            uri="ftp://servicemix:rocks@localhost/smx/test" />
Info
titleSender endpoint attributes
borderStylesolidbgColor='lighblue'

Name

Type

Description

Required

service

QName

the service name of the proxied endpoint

yes

endpoint

String

the endpoint name of the proxied endpoint

yes

interfaceName

QName

the interface name of the proxied endpoint

no

uri

URI

the ftp uri to access the FTP server (see #URI)

yes

autoCreateDirectory

boolean

creates dir if doesn't exist
(available since 2009.01)

true

overwrite

boolean

if a file with the same name already exists on the FTP server, overwrite it

no (defaults to false)

uniqueFileName

String

name used to create unique files when the marshaler can not give a specific file name

no (defaults to "ServiceMix")

marshaler

FileMarshaler

a marshaler can be used to customize how the file is read / written (see #Marshalers)

no

clientPool

FTPClientPool

provide specific configuration for the FTP client pool (see {#FTPClientPool])

no

uploadSuffix

String

the file will be uploaded with this suffix (e.g. .tmp) and renamed when the upload is complete
(available since version 3.1.1)

no

URI

You can use the familiar file URI to communicate with FTP servers. All types of endpoints use this standard URI to retrieve the needed parameters.

Code Block
ftp://[username[:password]@]host[:port]/[path]

where the parameters are:

  • username: the login to use to access the FTP server
  • password: the password
  • host: adress of the FTP server (IP or name)
  • port: port of the FTP server (defaults to 21)
  • path: the directory on the FTP server to change into

Marshalers

By default, poller endpoints expect the content of the file to be an xml, and sender endpoints write the xml content of the incoming NormalizedMessage to the remote file. This behavior can be customized by using a custom FileMarshaler.

FTPClientPool

The FTPClientPool is used to to retrieve connections and perform FTP calls to the server. By default, one is created and populated with the information retrieved from the URI (login, password, host, port). However, if more information needs to be configured, this is the place to do so.