View Source

{section}
{column}

{warning}This version must be installed on [Petals ESB 5.3.0|petalsesb530:Petals ESB 5.3.0]+{warning}

h1. Features

The FileTransfer component is a Binding Component which supports file transfers.

This component allows to:

* Expose a file system access as a service which provide a set of 8 operations:
** *put:* Write the received JBI messages in a file with a specified name
** *mput:* Write the JBI message attachments it receives into files.
** *get:* Retrieve *XML* file corresponding to a pattern, from a folder. Return it as message payload.
** *getAsAttachment:* Retrieve the first file corresponding to a pattern, from a folder. Return it as message's attachment.(XOP standard)
** *mGet:* Retrieve files corresponding to a pattern, from a folder. Return them as message's attachment.
** *checkFile:* Check the availability of a file.
** *del:* Delete one file.
** *dir:* List the content of a folder.

* Poll a configured directory for incoming files. At a poll, each file retrieved is put into a new JBI message, set as source or attachment. The message is sent to a target JBI service.

{info}All attachment are processed by using XOP rules.(XML-binary Optimized Packaging : [http://www.w3.org/TR/xop10/] ){info}

{column}
{column:width=25%}
{panel:title=Table of contents}{toc:outline=true}{panel}
{panel:title=Contributors}{contributors:order=name|mode=list|showAnonymous=true|showCount=true|showLastTime=true}{panel}
{column}
{section}

h1. Exposing a file system access as a service (Provides mode)

{info}
All operations support wild card character.
{info}

{tip}
All operations are in namespace {{http://petals.ow2.org/components/filetransfer/version-5}}.
{tip}

h2. Usage

h3. Put Operation

When the _put_ operation is set on the incoming IN message, the component writes the XML message to the configured directory.

The created file takes the name described in the service unit (filename parameter) otherwise the operation name is taken. For each file created, the system date is appended to this file name.

The IN message looks like :
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<ver:put xmlns:ver="http://petals.ow2.org/components/filetransfer/version-5">?</ver:put>
{code}
The service does not return a message.
The available exchange pattern is : *InOnly*.

h3. MPut Operation

When the _mput_ operation is set on the incoming IN message, the component writes the attachments on the configured directory.
The IN message looks like :
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<ver:mput xmlns:ver="http://petals.ow2.org/components/filetransfer/version-5">
<ver:attachments>
<!--1 or more repetitions:-->
<ver:filename><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:test1.xml"/></ver:filename>
<ver:filename><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:test2.xml"/></ver:filename>
</ver:attachments>
</ver:mput>
{code}

The service does not return a nominal response. It might return fault on following conditions, otherwise an error is returned:
* when no attachment is provided in the request, the fault '{{fileAttachmentExpected}}' is returned.

The available exchange pattern is : *InOnly*.

h3. Get Operation

When the _get_ operation is set on the incoming IN message, the component retrieves ONE file from the configured directory and return it as an XML message content. By default, the file is moved to the backup directory configured at service unit level.

The name of the file to retrieve is set in the XML IN content of the message.

The IN message looks like :
{code:lang=xml}<?xml version="1.0" encoding="UTF-8"?>
<ver:get xmlns:ver="http://petals.ow2.org/components/filetransfer/version-5">
<ver:filename>file name to retrieve</ver:filename>
</ver:get>
{code}
The OUT message returned to the consumer is the content of the XML file.

The service might return fault on following conditions, otherwise an error is returned:
* when the element '{{filename}}' is missing in the request, the fault '{{filenameMissing}}' is returned,
* when the expected file is not found, the fault '{{noFileFound}}' is returned,
* when the expected file is not a XML file, the fault '{{xmlFileExpected}}' is returned,
* when the expected file is locked for writing by another process, the fault '{{fileLocked}}' is returned.

The available exchange patterns is : *InOut*.

{info}Only xml file could be processed otherwise an error will be raised.{info}

h3. GetAsAttachement Operation

When the _getAsAttachment_ operation is set on the incoming IN message, the component retrieve ONE file from the configured directory according to the filename(or filter) set in the XML request. By default, the file is moved to the backup directory configured at service unit level.
The retrieved file is set in the OUT message as an attachment.

The IN message looks like:
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<ver:getAsAttachment xmlns:ver="http://petals.ow2.org/components/filetransfer/version-5">
<ver:filename>file name to retrieve</ver:filename>
</ver:getAsAttachment>
{code}

The OUT message returned to the consumer contains file, as attachment:
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<tns:getAsAttachmentResponse xmlns:tns="http://petals.ow2.org/components/filetransfer/version-5">
<tns:file-content>
<xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:test1.xml"/>
</tns:file-content>
</tns:getAsAttachmentResponse>
{code}

The service might return fault on following conditions, otherwise an error is returned:
* when the element '{{filename}}' is missing in the request, the fault '{{filenameMissing}}' is returned,
* when the expected file is not found, the fault '{{noFileFound}}' is returned,
* when the expected file is locked for writing by another process, the fault '{{fileLocked}}' is returned.

The available exchange pattern is : *InOut*.

h3. MGet Operation

When the _mget_ operation is set on the incoming IN message, the component retrieves files from the configured directory, according to the filenames (or filters) set in the XML request. By default, the files returned are moved to the backup directory configured at service unit level.
There is no recursion, sub folders are ignored.

Each file is set in the OUT message as an attachment.
The IN message looks like:
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<ver:mget xmlns:ver="http://petals.ow2.org/components/filetransfer/version-5">
<\!\--1 or more repetitions:-\->
<ver:filename>*.xml</ver:filename>
<ver:filename>myFile.txt</ver:filename>
</ver:mget>
{code}

The OUT message returned to the consumer contains files, as attachments:
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<tns:mgetResponse xmlns:tns="http://petals.ow2.org/components/filetransfer/version-5">
<tns:file-content><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:test1.xml"/></tns:file-content>
<tns:file-content><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:myFile.txt"/></tns:file-content>
</tns:mgetResponse>
{code}

The service might returns error but no fault.

If a file matching request criteria is locked for writing by another process, it will not be returned until it is unlocked.

The available exchange pattern is : *InOut*.

h3. CheckFile Operation

When the _check_ operation is set on the incoming IN message, the component check
if the specified file exist. The IN message looks like&nbsp;:
{code:lang=xml}
<ver:checkFile xmlns:ver="http://petals.ow2.org/components/filetransfer/version-5">
<ver:filename>?</ver:filename>
</ver:checkFile>
{code}

The OUT message returned to the consumer looks like&nbsp;:
{code:lang=xml}
<ver:checkFileResponse xmlns:ver="http://petals.ow2.org/components/filetransfer/version-5">
<ver:filename>?</ver:filename>
<ver:exist>true|false</ver:exist>
</ver:checkFileResponse>
{code}

The service might return fault on following conditions, otherwise an error is returned:
* when the element '{{filename}}' is missing in the request, the fault '{{filenameMissing}}' is returned.

The available exchange pattern is : *InOut*.

h3. Del Operation

When the _del_ operation is set on the incoming IN message, the component deletes the remote files. The IN message looks like :
{code:lang=xml}<?xml version="1.0" encoding="UTF-8"?>
<ver:del xmlns:ver="http://petals.ow2.org/components/filetransfer/version-5">
<ver:filename>?</ver:filename>
</ver:del>
{code}

The service does not return a nominal response. It might return fault on following conditions, otherwise an error is returned:
* when the element '{{filename}}' is missing in the request, the fault '{{filenameMissing}}' is returned.

The available exchange pattern is : *InOnly*.

h3. Dir Operation

When the _dir_ operation is set on the incoming IN message, the component returns the file names listed from the configured directory. A wild card expression can be given to filter files returned. f no wild card expression is given, or if it is empty, all files will be listed:
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<ver:dir xmlns:ver="http://petals.ow2.org/components/filetransfer/version-5" >
<ver:filename>*.xml</ver:filename>
</ver:dir>
{code}

The OUT message returned to the consumer looks like&nbsp;:
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<tns:dirResponse xmlns:tns="http://petals.ow2.org/components/filetransfer/version-5">
<tns:filename>file.xml</tns:filename>
<tns:filename>file1.xml</tns:filename>
<tns:filename>file2.xml</tns:filename>
</tns:dirResponse>
{code}

The service might return an ioFault.
The available exchange pattern is : *InOut*.

h2. Configuration

All needed information must be defined in the service-unit JBI descriptor. This JBI descriptor is configured through parameters divided in following groups:
* *JBI parameters* that defines the service provider identification,
* *CDK parameters* that are parameters driving the service provider implementation at CDK layer,
* *CDK interceptor parameters* that are parameters driving interceptors at CDK layer,
* *Dedicated parameters* that are parameters driving the service provider implementation at component layer.

h3. CDK parameters defining service provider implementation
The following parameters correspond to the CDK configuration of the service provider implementation.

{include:0 CDK SU Provide Configuration 5.8.0}

h3. CDK parameters driving interceptors
The following parameters drive interceptors at CDK layer.

{include:0 CDK SU Interceptor configuration 5.8.0}

h3. Dedicated configuration

{table-plus}
|| Attribute || Description || Default value || Required ||
| {{filename}} | The name of the file where the JBI message (the XML content) will be written in. \\
The system date is appended on each created file. | The operation name | {center}No{center} |
| {{backup-directory}} | The directory where files are moved after to be read. Environment variables are supported with the form $\{myEnvVariable\}. | {center}system's temporary directory{center} | {center}No{center} |
| {{folder}} | Working directory where files are written or retrieved. Environment variables are supported with the form $\{myEnvVariable\} | | {center}Yes{center} |
| {{is-read-only}} | For operations getting files, if set to 'true', files are not moved to the backup directory (see {{backup-directory}}). | {center}{{false}}{center} | {center}Yes{center} |
| {{locking-wait-time}} | For operations getting files, the maximum wait time (in seconds) for a locked file to be unlocked before to return the fault '{{fileLocked}}'. | {center}Value of '{{locking-wait-time}}' defined at component level{center} | {center}No{center} |
| {{locking-poll-interval}} | For operations getting files, the polling interval (in milliseconds) to check the maximum wait time for locked files. | {center}Value of '{{locking-poll-interval}}' defined at component level{center} | {center}No{center} |
{table-plus}

h3. Service Unit content

The service unit has to contain the following elements, packaged in the archive:
* the META-INF/jbi.xml descriptor file as described above,
* it is also highly recommended to provide a WSDL description for service provider embedded in the service-unit. The service provider contract must implement the interface "\{http://petals.ow2.org/components/filetransfer/version-5}FileTransfer" defined in the abstract WSDL 'FileTransferInterface.wsdl' available as resource in the component archive.

{code}
service-unit.zip
+ META-INF
- jbi.xml (as defined above)
- service.wsdl (recommended)
{code}

h3. Example

An example of a Service Unit descriptor to provide an Filetransfer service:
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<jbi:jbi version="1.0"
xmlns:filetransfer="http://petals.ow2.org/components/filetransfer/version-5"
xmlns:generateNs="http://petals.ow2.org/filetransfer"
xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-5"
xmlns:jbi="http://java.sun.com/xml/ns/jbi"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<jbi:services binding-component="true">

<jbi:provides endpoint-name="myFileTransferSUEndpointName"
interface-name="filetransfer:FileTransfer" service-name="generateNs:myFileTransferSUServiceName">

<!-- CDK specific elements -->
<petalsCDK:wsdl>MyFileTransferService.wsdl</petalsCDK:wsdl>
<petalsCDK:validate-wsdl>true</petalsCDK:validate-wsdl>

<!-- Component specific elements -->
<filetransfer:filename>gettingstarted.xml</filetransfer:filename>
<filetransfer:backup-directory>${PETALS_HOME}/filetransfer/backup</filetransfer:backup-directory>
<filetransfer:folder>${PETALS_HOME}/filetransfer/out</filetransfer:folder>
</jbi:provides>
</jbi:services>
</jbi:jbi>
{code}

h1. Invoking service on incoming file (Consumes mode)

If you want to invoke a service provider in Petals ESB with files, put the files in the configured directory ({{folder}). At each configured polling period ({{polling-period}}), the component fetches the incoming files.

For each received files and according to the transfer mode ({{transfer-mode}} or {{base-msg}}), the component creates a new message exchange and attaches the file, either as source or attachment.

If a file is put as a attachment, the name of the attachment is set to the name of the file, and in the source of the message exchange, the component put a XML structure according to MTOM optimization rules.

The resulted message exchange(s) are sent to the target endpoint.

During the transfer, if the backup directory ({{backup-directory}}) is set, the transfered file is moved into it and never deleted by the component. Otherwise the file is moved to the system temporary directory.

{note}
A InOut service provider can be exposed to be consumed through files. The content of its reply will be ignored. By default the message exchange pattern used to send messages to the service provider is '{{InOnly}}'. Just set the right value into the parameter {{mep}} in the section {{consumes}} of the SU JBI descriptor.
{note}

When deploying a service unit like in the following code snippet, all the files put in the directory {{$PETALS_HOME/filetransfer/in}} would be set as the payload of an invocation to the _ftContentNoBaseMsgService_ service.

h2. Configuration

All needed information must be defined in the service-unit JBI descriptor. This JBI descriptor is configured through parameters divided in following groups:
* *JBI parameters* that defines the service provider identification,
* *CDK parameters* that are parameters driving the service consumer implementation at CDK layer,
* *CDK interceptor parameters* that are parameters driving interceptors at CDK layer,
* *Dedicated parameters* that are parameters driving the service consumer implementation at component layer.

h3. CDK parameters defining service consumer implementation
The following parameters correspond to the CDK configuration of the service consumer implementation.

{include:0 CDK SU BC Consume Configuration 5.8.0}

h3. CDK parameters driving interceptors
The following parameters drive interceptors at CDK layer.

{include:0 CDK SU Interceptor configuration 5.8.0}

h3. Dedicated configuration

{table-plus}
|| Attribute || Description || Default Value || Required ||
| folder | Working directory where files are written or retrieved. $ \{myEnvVariable\} environment variables are supported. | {center}\-{center} | {center}Yes{center} |
| backup-directory | The directory where files are moved before being read.Environment variables are supported with the form $\{myEnvVariable\}. | {center}default system temporary directory {center} | {center}No{center} |
| polling-period | Polling period in milliseconds | {center}1000{center} | {center}No{center} |
| filename | Pattern used filter files to read | {center}\*{center} | {center}No{center} |
| transfer-mode | The mode of transfer of the received file(s) as message payload. \\
Accepted values : content, attachment. | {center}attachment{center} | {center}No{center} |
| base-message | The skeleton of XML-message to send to the consumed service. It may contain *$content* or *$attachment*, or none of them. This is the way the component should link the file with the returned message. \\
* *$content* will be replaced by the file content.
* *$attachment* will set the file in attachment. It will be replaced by a xop:include element which references the attachment (MTOM-like). | {center}\-{center} | {center}No{center} |
| external-processor-thread-pool-size | For each service-unit, the component create a poller. This parameter defines the maximum number of processor thread created by the poller to process incoming files until the service provider invocation. If no more processor thread is available, the associated incoming file to process will be postponed after the next polling period. | {center}5{center} | {center}No{center} |
| external-processor-thread-pool-timeout | Define the max wait time, in millisecond, to get a thread from the pool. If not possible, the associated incoming file to process will be postponed after the next polling period. | {center}10000ms{center} | {center}No{center} |
| external-processor-block-size | Define the number of incoming files processed concurrently in the sliding window, or '0' for no limitation. | {center}0{center} | {center}No{center} |
| external-processor-max-wait | Define the max waiting time, in millisecond, that an incoming file waits to enter in the sliding window. If it can't, its processing will be postponed after the next polling period. This parameter has no sens if external-processor-block-size is set to '0'. | {center}500ms{center} | {center}No{center} |
{table-plus}

{note}The parameter "transfer-mode" and "base-msg" can not be used at the same time.{note}

h3. Service unit content

The service unit has to contain the following elements, packaged in the archive:
* the META-INF/jbi.xml descriptor file as described above,.

{code}
service-unit.zip
+ META-INF
- jbi.xml (as defined above)
{code}

h3. Example

*Example 1*: use of the parameter '*transfer-mode*'
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<jbi:jbi version="1.0"
    xmlns:providerNs="http://petals.ow2.org/filetransfer/my-provider"
xmlns:filetransfer="http://petals.ow2.org/components/filetransfer/version-5"
xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-5"
    xmlns:jbi="http://java.sun.com/xml/ns/jbi"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <jbi:services binding-component="false">
        <jbi:consumes
interface-name="providerNs:ftContentNoBaseMsg"
            service-name="providerNs:ftContentNoBaseMsgService"
            endpoint-name="ftContentNoBaseMsgEndpoint">

            <petalsCDK:timeout>20</petalsCDK:timeout>
            <petalsCDK:mep>InOnly</petalsCDK:mep>
            <petalsCDK:operation>providerNs:simplefiletransfer</petalsCDK:operation>

            <filetransfer:folder>${PETALS_HOME}/filetransfer/in</filetransfer:folder>
            <filetransfer:polling-period>3000</filetransfer:polling-period>
            <filetransfer:transfer-mode>content</filetransfer:transfer-mode>
        </jbi:consumes>
    </jbi:services>
</jbi:jbi>
{code}

*Example 2*: use of the parameter '*base-msg*'
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<jbi:jbi version="1.0"
xmlns:providerNs="http://petals.ow2.org/filetransfer/my-provider"
    xmlns:filetransfer="http://petals.ow2.org/components/filetransfer/version-5"
    xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-5"
xmlns:jbi="http://java.sun.com/xml/ns/jbi"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <jbi:services binding-component="true">
        <jbi:consumes
interface-name="providerNs:ftAttachmentBaseMsg"
            service-name="providerNs:ftAttachmentBaseMsgService"
endpoint-name="ftAttachmentBaseMsgEndpoint">

            <petalsCDK:timeout>30000</petalsCDK:timeout>
            <petalsCDK:mep>InOnly</petalsCDK:mep>
<petalsCDK:operation>providerNs:simplefiletransfer</petalsCDK:operation>

            <filetransfer:folder>${PETALS_HOME}/filetransfer/in4</filetransfer:folder>
            <filetransfer:polling-period>1000</filetransfer:polling-period>
            <filetransfer:base-message>
<![CDATA[<customMessage><attachments><filein>$attachment</filein></attachments></customMessage>]]>
</filetransfer:base-message>
        </jbi:consumes>
    </jbi:services>
</jbi:jbi>
{code}

h1. Configuring the component

The component can be configured through the parameters of its JBI descriptor file. These parameters are divided in following groups:
* *JBI parameters* that have not to be changed otherwise the component will not work,
* *CDK parameters* that are parameters driving the processing of the CDK layer,
* *Dedicated parameters* that are parameters specific to this component.

h2. CDK parameters
The component configuration includes the configuration of the CDK. The following parameters correspond to the CDK configuration.

{include:0 CDK Component Configuration Table 5.8.0}

h2. Interception configuration
{include:0 CDK Component Interceptor configuration 5.8.0}

h2. Dedicated configuration

These parameters drive features proposed by the component
{table-plus}
|| {color:#333333}Parameter{color} || {color:#333333}Description{color} || {color:#333333}Default{color} || {color:#333333}Required{color} || Scope ||
| {{locking-wait-time}} | For operations getting files, the maximum wait time (in seconds) for a locked file to be unlocked before to return the fault '{{fileLocked}}'. Can be overriden by service unit configuration. | {center}5{center} | {center}No{center} | {center}Installation & Runtime{center} |
| {{locking-poll-interval}} | For operations getting files, the polling interval (in milliseconds) to check the maximum wait time for locked files. Can be overriden by service unit configuration. | {center}500{center} | {center}No{center} | {center}Installation & Runtime{center} |

h1. Business monitoring

h2. MONIT traces

{include:0 CDK BC Business Monitoring Traces 5.8.0}

h2. Flow tracing activation

{include:0 CDK BC Provides Business Monitoring Flow Tracing Activation 5.8.0}

h1. Monitoring the component

h2. Using metrics

Several probes providing metrics are included in the component, and are available through the JMX MBean '{{org.ow2.petals:type=custom,name=monitoring_*<component-id>*}}', where {{*<component-id>*}} is the unique JBI identifier of the component.

h3. Common metrics

{include:0 CDK Component Monitoring Metrics 5.8.0}

h3. Dedicated metrics

No dedicated metric is available.

h2. Receiving alerts

Several alerts are notified by the component through notification of the JMX MBean '{{org.ow2.petals:type=custom,name=monitoring_*<component-id>*}}', where {{*<component-id>*}} is the unique JBI identifier of the component.

{tip}To integrate these alerts with Nagios, see [petalsesbsnapshot:Receiving Petals ESB defects in Nagios].{tip}

h3. Common alerts

{include:0 CDK Component Monitoring Alerts 5.6.0}

h3. Dedicated alerts

No dedicated alert is available.

h1. Known problems

h2. Encoding problem about filename on a filesystem mounted through Samba

An encoding problem can occurs about filename with Sambe mounts.
Please check that the encoding is correctly configured at Samba level through the parameters '{{unix charset}}' and '{{display charset}}'.