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 |
protected static TimeInterval |
DEFAULT_OLDER_THAN |
protected java.io.FileFilter |
fileFilter |
protected FileTransferClient |
ftpClient |
log
CONFIRMATION_ID_KEY
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() |
java.lang.String |
getFileFilterImp() |
TimeInterval |
getQuietInterval() |
void |
init()
Initialises the component.
|
protected boolean |
oldEnough(java.lang.String fullPath) |
protected long |
olderThanMs() |
protected void |
prepareConsumer() |
protected int |
processMessages()
Implemented by protocol-specific sub-classes.
|
void |
setFileFilterImp(java.lang.String s)
Set the filename filter implementation that will be used for filtering 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, getDestination, registerAdaptrisMessageListener, renameThread, requestClose, requestInit, requestStart, requestStop, retrieveAdaptrisMessageListener, retrieveComponentState, setDestination
createName, createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory
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
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 fileFilterImp()
public java.lang.String getFileFilterImp()
public void setFileFilterImp(java.lang.String s)
The String
expression that is used to filter messages is obtained from ConsumeDestination
.
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.
s
- The fileFilterImp to set, if not specified, then the default is
org.apache.commons.io.filefilter.RegexFileFilter
which uses the
java.util regular expressions to perform filteringConsumeDestination.getFilterExpression()
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()