Vous êtes sur la page 1sur 4

File Adapter:

Some of the functions in the file adapter are:


#[function:dateStamp]
#[function:datestamp:dd-MM-yy]
#[function:systime]
#[function:uuid]
#[header:originalFilename]
#[function:count]
#[header:message property name]
o
Configuration Options
File Transport inbound endpoint attributes
Name Description Default
autoDelete set this attribute to false if you don't want Mule to delete the file
once processed
true
fileAge setting this value (minimum age in milliseconds for a file to be
processed) is useful when consuming large files, as Mule will wait
before reading this file until the file last modification timestamp
indicates that the file is older than this value
true
moveToDirectory use this parameter if you want Mule to save a backup copy of the
file it reads

moveToPattern use this parameter together with moveToPattern if you want to
rename the copy of the backuped file

pollingFrequency the frequency in milliseconds that the read directory should be
checked
0
recursive use this parameter if Mule should recurse when a directory is read false
streaming if you want the payload to be a byte array instead of a
FileInputStream set this parameter to false
true
workDirectory if you require moving input files before they are processed by
Mule, then assign a working directory (in the same file system)
with this parameter

workFileNamePattern use this parameter together with workDirectory if you need to
rename input files prior to processing them


Name Type Requir
ed
Defa
ult
Description
writeToDirector
y
string no The directory path where the file should be written on
dispatch. This path is usually set as the endpoint of the
dispatch event, however this allows you to explicitly
force a single directory for the connector.
readFromDirect
ory
string no The directory path where the file should be read from.
This path is usually set as the inbound endpoint,
however this allows you to explicitly force a single
directory for the connector.
autoDelete boole
an
no true If set to true (the default), it will cause the file to be
deleted once it is read. If streaming is turned on, this
occurs when the InputStream for the file is closed.
Otherwise the file will be read into memory and
deleted immediately. To access the java.io.File object
set this property to false and specify a
NoActionTransformer transformer for the connector.
Mule will not delete the file, so it is up to the
component to delete it when it is done. If the
moveToDirectory is set, the file is first moved, then the
File object of the moved file is passed to the
component. It is recommended that a moveToDirectory
is specified when turning autoDelete off.
outputAppend boole
an
no false Whether the output should be appended to the existing
file. Default is false.
serialiseObjects boole
an
no Determines whether objects should be serialized to the
file. If false (the default), the raw bytes or text is
written.
streaming boole
an
no true Whether a FileInputStream should be sent as the
message payload (if true) or a byte array. (if false). The
default is true.
workDirectory string no (As of Mule 2.1.4) The directory path where the file
should be moved to prior to processing. The work
directory must reside on the same file system as the
read directory.
workFileNameP
attern
string no (As of Mule 2.1.4) The pattern to use when moving a
file to a new location determined by the workDirectory
property. You can use the patterns supported by the
filename parser configured for this connector.
recursive boole
an
no false Whether to recurse or not when a directory is read
pollingFrequenc
y
long no The frequency in milliseconds that the read directory
should be checked (default is 0). Note that the read
directory is specified by the endpoint of the listening
component.
fileAge long no Miniumum age (ms) for a file to be processed. This can
be useful when consuming large files. It tells Mule to
wait for a period of time before consuming the file,
allowing the file to be completely written before the
file is processed.
moveToPattern string no The pattern to use when moving a read file to a new
location determined by the moveToDirectory property.
This can use the patterns supported by the filename
parser configured for this connector.
moveToDirector
y
string no The directory path where the file should be written
after it has been read. If this is not set, the file is
deleted after it has been read.
comparator class
name
no Sorts incoming files using the specified comparator,
such as
comparator="org.mule.transport.file.comparator.Older
FirstComparator". The class must implement the
java.util.Comparator interface.
reverseOrder boole
an
no Whether the comparator order should be reversed.
Default is false.
outputPattern string no The pattern to use when writing a file to disk. This can
use the patterns supported by the filename parser
configured for this connector.


Filename wildcard filter
The filename-wildcard-filter element configures a filter that can be used to restrict the files being
processed by applying wildcard expressions to the filename. For example, you can read only .xml and .txt
files by entering the following: <file:filename-wildcard-filter pattern=".txt,.xml"/>
Filename regex filter
The filename-regex-filter element configures a filter that can be used to restrict the files being processed
by applying Java regular expressions to the filename, such as pattern="myCustomerFile(.*)".
Expression filename parser
The expression-filename-parser element configures the ExpressionFilenameParser, which can use any
expression language supported by Mule to construct a file name for the current message. Expressions can
be xpath, xquery, ognl, mvel, header, function, and more.
Following is an example of using the parser:
<file:connector name="FileConnector" >
<file:expression-filename-parser/>
</file:connector>
...
<file:outbound-endpoint path="file://temp"
outputPattern="#[header:originalFilename]--#[function:datestamp].txt"/>
#[MULE3USER:DATE] : #[function:dateStamp]
#[DATE:dd-MM-yy] : #[function:datestamp:dd-MM-yy]
#[MULE3USER:SYSTIME] : #[function:systime]
#[MULE3USER:UUID] : #[function:uuid]
#[MULE3USER:ORIGINALNAME] : #[header:originalFilename]
#[MULE3USER:COUNT] : #[function:count] - note that this is a global counter. If you want a
local counter per file connector then you should use the legacy-filename-parser.
#[MULE3USER:message property name] : #[header:message property name]

Custom filename parser
The custom-filename-parser element allows the user to specify a custom filename parser. The
implementation must implement org.mule.transport.file.FilenameParser.

Vous aimerez peut-être aussi