public abstract class FtpConsumerImpl extends AdaptrisPollingConsumer
AdaptrisMessageConsumer
implementation.AdaptrisPollingConsumer.LockOperator
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
DEFAULT_FILE_FILTER_IMPL
Deprecated.
since 3.11.1 {@link FileFilterBuilder#DEFAULT_FILE_FILTER_IMP instead.
|
protected static TimeInterval |
DEFAULT_OLDER_THAN |
protected java.io.FileFilter |
fileFilter |
protected FileTransferClient |
ftpClient |
log
Constructor and Description |
---|
FtpConsumerImpl() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
accept(java.lang.String path) |
protected boolean |
additionalDebug() |
protected AdaptrisMessage |
addStandardMetadata(AdaptrisMessage msg,
java.lang.String filename,
java.lang.String dir) |
protected java.lang.String |
configureWorkDir(java.lang.String path) |
java.lang.String |
consumeLocationKey()
Provides the metadata key '"fsConsumeDir"' that
contains the directory (if not null) where the file was read from.
|
protected abstract boolean |
fetchAndProcess(java.lang.String fullPath) |
protected java.lang.String |
fileFilterImp() |
protected java.lang.String |
filterExpression() |
protected java.lang.String |
ftpURL() |
ConsumeDestination |
getDestination()
Deprecated.
|
java.lang.String |
getFileFilterImp()
Set the filename filter implementation that will be used for filtering files.
|
java.lang.String |
getFilterExpression()
The filter expression to use when listing files.
|
java.lang.String |
getFtpEndpoint()
The FTP endpoint where we will retrieve files files.
|
TimeInterval |
getQuietInterval() |
void |
init()
Initialises the component.
|
protected java.lang.String |
newThreadName() |
protected boolean |
oldEnough(java.lang.String fullPath) |
protected long |
olderThanMs() |
protected void |
prepareConsumer() |
protected int |
processMessages()
Implemented by protocol-specific sub-classes.
|
void |
setDestination(ConsumeDestination destination)
Deprecated.
|
void |
setFileFilterImp(java.lang.String fileFilterImp)
Set the filename filter implementation that will be used for filtering files.
|
void |
setFilterExpression(java.lang.String filterExpression)
The filter expression to use when listing files.
|
void |
setFtpEndpoint(java.lang.String ftpEndpoint)
The FTP endpoint where we will retrieve files files.
|
void |
setQuietInterval(TimeInterval interval)
Specify the time in which a file has been untouched before it is deemed safe to be processed.
|
close, continueProcessingMessages, getMaxMessagesPerPoll, getPoller, getReacquireLockBetweenMessages, prepare, releaseLock, setMaxMessagesPerPoll, setPoller, setReacquireLockBetweenMessages, start, stop
changeState, registerAdaptrisMessageListener, renameThread, requestClose, requestInit, requestStart, requestStop, retrieveAdaptrisMessageListener, retrieveComponentState
createName, createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory, withUniqueID
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactory
getUniqueId
createName, createQualifier, isTrackingEndpoint
protected static final TimeInterval DEFAULT_OLDER_THAN
@Deprecated protected static final java.lang.String DEFAULT_FILE_FILTER_IMPL
protected transient java.io.FileFilter fileFilter
protected transient FileTransferClient ftpClient
public void init() throws CoreException
ComponentLifecycle
Component initialisation includes config verification, creation of connections etc.
init
in interface ComponentLifecycle
init
in class AdaptrisPollingConsumer
CoreException
- wrapping any underlying Exception
sComponentLifecycle.init()
protected boolean additionalDebug()
protected boolean oldEnough(java.lang.String fullPath) throws FileTransferException, java.io.IOException
FileTransferException
java.io.IOException
protected AdaptrisMessage addStandardMetadata(AdaptrisMessage msg, java.lang.String filename, java.lang.String dir)
protected int processMessages()
AdaptrisPollingConsumer
Implemented by protocol-specific sub-classes.
processMessages
in class AdaptrisPollingConsumer
protected abstract boolean fetchAndProcess(java.lang.String fullPath) throws java.lang.Exception
java.lang.Exception
protected java.lang.String configureWorkDir(java.lang.String path)
protected boolean accept(java.lang.String path) throws java.lang.Exception
java.lang.Exception
protected void prepareConsumer() throws CoreException
prepareConsumer
in class AdaptrisPollingConsumer
CoreException
protected java.lang.String ftpURL()
protected java.lang.String filterExpression()
protected java.lang.String newThreadName()
newThreadName
in class AdaptrisMessageConsumerImp
protected java.lang.String fileFilterImp()
protected long olderThanMs()
public TimeInterval getQuietInterval()
public void setQuietInterval(TimeInterval interval)
The purpose of this is to delay processing of files that may be currently being written to by another process. On certain platforms (e.g. most Unix) it is still possible to obtain an exclusive lock on the file even though it is being written to by another process.
Note: your mileage may vary when using this setting. The FTP Server and the FTP Client will almost certainly have to time-synchronized. Depending on the FTP Server implementation in question, you may need to additionally specify the server's timezone in order to get accurate information.Additionally, the remote FTP server needs to support support the MDTM command.
interval
- the quietPeriod to set (default to 0)FtpConnectionImp.setServerTimezone(String)
,
CompositeFileFilter
,
setFileFilterImp(String)
public java.lang.String consumeLocationKey()
public java.lang.String getFileFilterImp()
The file filter implementation that is used in conjunction with the
getFilterExpression()
, if not specified, then the default is
org.apache.commons.io.filefilter.RegexFileFilter
which uses the java.util regular
expressions to perform filtering
The expression that is used to filter messages is derived from getFilterExpression()
or from the deprecated getDestination()
.
Note that because we working against a remote server, support for additional file attributes
such as size (e.g. via SizeGreaterThan
) or last modified may not
be supported. We encourage you to stick with filtering by filename only.
getFilterExpression()
public void setFileFilterImp(java.lang.String fileFilterImp)
The file filter implementation that is used in conjunction with the
getFilterExpression()
, if not specified, then the default is
org.apache.commons.io.filefilter.RegexFileFilter
which uses the java.util regular
expressions to perform filtering
The expression that is used to filter messages is derived from getFilterExpression()
or from the deprecated getDestination()
.
Note that because we working against a remote server, support for additional file attributes
such as size (e.g. via SizeGreaterThan
) or last modified may not
be supported. We encourage you to stick with filtering by filename only.
getFilterExpression()
@Deprecated public ConsumeDestination getDestination()
@Deprecated public void setDestination(ConsumeDestination destination)
public java.lang.String getFtpEndpoint()
Although nominally a URL, you can configure the following styles
FileTransferConnection
will be used to supply the username and
password. You will be working off directly off the perceived root filesystem which will be a
problem if you aren't in a chroot jail.ftp://10.0.0.1/path/to/dir
, the username and password will be taken
from the corresponding connection. The working directory start with /path/to/dir
ftp://user:password@10.0.0.1/path/to/dir
.
The working directory will start with /path/to/dir
public void setFtpEndpoint(java.lang.String ftpEndpoint)
Although nominally a URL, you can configure the following styles
FileTransferConnection
will be used to supply the username and
password. You will be working off directly off the perceived root filesystem which will be a
problem if you aren't in a chroot jail.ftp://10.0.0.1/path/to/dir
, the username and password will be taken
from the corresponding connection. The working directory start with /path/to/dir
ftp://user:password@10.0.0.1/path/to/dir
.
The working directory will start with /path/to/dir
public java.lang.String getFilterExpression()
If not specified then will default in a file filter that matches all files.
public void setFilterExpression(java.lang.String filterExpression)
If not specified then will default in a file filter that matches all files.