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
FieldsModifier and TypeFieldDescriptionprotected static final StringDeprecated.protected static final TimeIntervalprotected FileFilterprotected FileTransferClientFields inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanprotected booleanprotected AdaptrisMessageaddStandardMetadata(AdaptrisMessage msg, String filename, String dir) protected StringconfigureWorkDir(String path) Provides the metadata key '"fsConsumeDir"' that contains the directory (if not null) where the file was read from.protected abstract booleanfetchAndProcess(String fullPath) protected Stringprotected Stringprotected StringftpURL()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 booleanvoidinit()Initialises the component.protected booleanprotected longprotected voidprotected intImplemented by protocol-specific sub-classes.voidsetFileFilterImp(String fileFilterImp) Set the filename filter implementation that will be used for filtering files.voidsetFilterExpression(String filterExpression) The filter expression to use when listing files.voidsetFtpEndpoint(String ftpEndpoint) The FTP endpoint where we will retrieve files files.voidsetQuietInterval(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, stopMethods inherited from class com.adaptris.core.AdaptrisMessageConsumerImp
changeState, newThreadName, registerAdaptrisMessageListener, renameThread, requestClose, requestInit, requestStart, requestStop, retrieveAdaptrisMessageListener, retrieveComponentStateMethods 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, withUniqueIDMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueIdMethods inherited from interface com.adaptris.core.AdaptrisMessageWorker
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactoryMethods 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_IMPinstead. -
fileFilter
-
ftpClient
-
-
Constructor Details
-
FtpConsumerImpl
public FtpConsumerImpl()
-
-
Method Details
-
init
Description copied from interface:ComponentLifecycleInitialises the component.Component initialisation includes config verification, creation of connections etc.
- Specified by:
initin interfaceComponentLifecycle- Overrides:
initin classAdaptrisPollingConsumer- Throws:
CoreException- wrapping any underlyingExceptions- See Also:
-
additionalDebug
protected boolean additionalDebug() -
oldEnough
- Throws:
FileTransferExceptionIOException
-
addStandardMetadata
-
processMessages
protected int processMessages()Description copied from class:AdaptrisPollingConsumerImplemented by protocol-specific sub-classes.
- Specified by:
processMessagesin classAdaptrisPollingConsumer
-
handle
-
fetchAndProcess
- Throws:
Exception
-
configureWorkDir
-
accept
- Throws:
Exception
-
prepareConsumer
- Specified by:
prepareConsumerin 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.RegexFileFilterwhich 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.RegexFileFilterwhich 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
FileTransferConnectionwill 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
FileTransferConnectionwill 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_IMPinstead.