Class FtpConsumerImpl
- All Implemented Interfaces:
AdaptrisComponent
,AdaptrisMessageConsumer
,AdaptrisMessageWorker
,ComponentLifecycle
,ComponentLifecycleExtension
,MessageEventGenerator
,StateManagedComponent
- Direct Known Subclasses:
FtpConsumer
,RelaxedFtpConsumer
AdaptrisMessageConsumer
implementation.-
Nested Class Summary
Nested classes/interfaces inherited from class com.adaptris.core.AdaptrisPollingConsumer
AdaptrisPollingConsumer.LockOperator
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
Deprecated.protected static final TimeInterval
protected FileFilter
protected FileTransferClient
Fields inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
log
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
protected boolean
protected AdaptrisMessage
addStandardMetadata
(AdaptrisMessage msg, String filename, String dir) protected String
configureWorkDir
(String path) Provides the metadata key '"fsConsumeDir"' that contains the directory (if not null) where the file was read from.protected abstract boolean
fetchAndProcess
(String fullPath) protected String
protected String
protected String
ftpURL()
Set the filename filter implementation that will be used for filtering files.The filter expression to use when listing files.The FTP endpoint where we will retrieve files files.protected boolean
void
init()
Initialises the component.protected boolean
protected long
protected void
protected int
Implemented by protocol-specific sub-classes.void
setFileFilterImp
(String fileFilterImp) Set the filename filter implementation that will be used for filtering files.void
setFilterExpression
(String filterExpression) The filter expression to use when listing files.void
setFtpEndpoint
(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.Methods inherited from class com.adaptris.core.AdaptrisPollingConsumer
close, continueProcessingMessages, getMaxMessagesPerPoll, getPoller, getReacquireLockBetweenMessages, prepare, releaseLock, setMaxMessagesPerPoll, setPoller, setReacquireLockBetweenMessages, start, stop
Methods inherited from class com.adaptris.core.AdaptrisMessageConsumerImp
changeState, newThreadName, registerAdaptrisMessageListener, renameThread, requestClose, requestInit, requestStart, requestStop, retrieveAdaptrisMessageListener, retrieveComponentState
Methods inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
createName, createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory, withUniqueID
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueId
Methods inherited from interface com.adaptris.core.AdaptrisMessageWorker
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactory
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createName, createQualifier, isTrackingEndpoint
-
Field Details
-
DEFAULT_OLDER_THAN
-
DEFAULT_FILE_FILTER_IMPL
Deprecated.since 3.11.1FileFilterBuilder.DEFAULT_FILE_FILTER_IMP
instead. -
fileFilter
-
ftpClient
-
-
Constructor Details
-
FtpConsumerImpl
public FtpConsumerImpl()
-
-
Method Details
-
init
Description copied from interface:ComponentLifecycle
Initialises the component.Component initialisation includes config verification, creation of connections etc.
- Specified by:
init
in interfaceComponentLifecycle
- Overrides:
init
in classAdaptrisPollingConsumer
- Throws:
CoreException
- wrapping any underlyingException
s- See Also:
-
additionalDebug
protected boolean additionalDebug() -
oldEnough
- Throws:
FileTransferException
IOException
-
addStandardMetadata
-
processMessages
protected int processMessages()Description copied from class:AdaptrisPollingConsumer
Implemented by protocol-specific sub-classes.
- Specified by:
processMessages
in classAdaptrisPollingConsumer
-
handle
-
fetchAndProcess
- Throws:
Exception
-
configureWorkDir
-
accept
- Throws:
Exception
-
prepareConsumer
- Specified by:
prepareConsumer
in classAdaptrisPollingConsumer
- Throws:
CoreException
-
ftpURL
-
filterExpression
-
fileFilterImp
-
olderThanMs
protected long olderThanMs() -
getQuietInterval
-
setQuietInterval
Specify the time in which a file has been untouched before it is deemed safe to be processed.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.
- Parameters:
interval
- the quietPeriod to set (default to 0)- See Also:
-
consumeLocationKey
Provides the metadata key '"fsConsumeDir"' that contains the directory (if not null) where the file was read from.- Returns:
- the metadata key;
- Since:
- 3.9.0
-
getFileFilterImp
Set the filename filter implementation that will be used for filtering files.The file filter implementation that is used in conjunction with the
getFilterExpression()
, if not specified, then the default isorg.apache.commons.io.filefilter.RegexFileFilter
which uses the java.util regular expressions to perform filteringThe expression that is used to filter messages is derived from
getFilterExpression()
.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.- See Also:
-
setFileFilterImp
Set the filename filter implementation that will be used for filtering files.The file filter implementation that is used in conjunction with the
getFilterExpression()
, if not specified, then the default isorg.apache.commons.io.filefilter.RegexFileFilter
which uses the java.util regular expressions to perform filteringThe expression that is used to filter messages is derived from
getFilterExpression()
.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.- See Also:
-
getFtpEndpoint
The FTP endpoint where we will retrieve files files.Although nominally a URL, you can configure the following styles
- Just the server name / IP Address (e.g. 10.0.0.1) in which case the username and password
from the corresponding
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. - A FTP style URL
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
- A FTP style URL with a username/password
ftp://user:password@10.0.0.1/path/to/dir
. The working directory will start with/path/to/dir
- Just the server name / IP Address (e.g. 10.0.0.1) in which case the username and password
from the corresponding
-
setFtpEndpoint
The FTP endpoint where we will retrieve files files.Although nominally a URL, you can configure the following styles
- Just the server name / IP Address (e.g. 10.0.0.1) in which case the username and password
from the corresponding
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. - A FTP style URL
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
- A FTP style URL with a username/password
ftp://user:password@10.0.0.1/path/to/dir
. The working directory will start with/path/to/dir
- Just the server name / IP Address (e.g. 10.0.0.1) in which case the username and password
from the corresponding
-
getFilterExpression
The filter expression to use when listing files.If not specified then will default in a file filter that matches all files.
-
setFilterExpression
The filter expression to use when listing files.If not specified then will default in a file filter that matches all files.
-
FileFilterBuilder.DEFAULT_FILE_FILTER_IMP
instead.