@ComponentProfile(summary="Pickup messages from an FTP or SFTP server", tag="consumer,ftp,ftps,sftp", metadata={"originalname","fsFileSize","fsConsumeDir","_interlokMessageConsumedFrom"}, recommended=FileTransferConnection.class) public class FtpConsumer extends FtpConsumerImpl
The connection type for this consumer should always be a concrete implementation of FileTransferConnection
.
The destination returned by the ConsumeDestination implementation should be in the form in the URL form dictated by the
FileTransferConnection
flavour or simply the IP Address / DNS name of the target Server. If the URL form is used,
then it is possible to override the username, password, and port settings of the server, in all other cases the configuration
specified in the FileTransferConnection
object will be used.
In the event the proc-directory is not configured, then after processing the file, it is deleted. If proc-directory is configured, then the remote file will be renamed to this directory
The configuration of this consumer closely mirrors that of the FsConsumer though it does not, at the moment, share any common hierarchy with a key difference; although multiple file-filters can be configured only filters that work with the filepath will work. Other filter implementations (such as those based on size /last modified) may not work.
FtpConnection
,
FileTransferConnection
,
ConsumeDestination
In the adapter configuration file this class is aliased as ftp-consumer which is the preferred alternative to the fully qualified classname when building your configuration.
AdaptrisPollingConsumer.LockOperator
DEFAULT_FILE_FILTER_IMPL, DEFAULT_OLDER_THAN, fileFilter, ftpClient
log
CONFIRMATION_ID_KEY
Constructor and Description |
---|
FtpConsumer() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
accept(java.lang.String path) |
protected java.lang.String |
configureWorkDir(java.lang.String path) |
protected boolean |
fetchAndProcess(java.lang.String fullPath) |
java.lang.String |
getProcDirectory()
Get the "proc" directory.
|
java.lang.String |
getWipSuffix() |
java.lang.String |
getWorkDirectory()
Get the work directory.
|
void |
init()
Initialises the component.
|
void |
setProcDirectory(java.lang.String s)
Set the directory where files are placed after processing.
|
void |
setWipSuffix(java.lang.String s)
Set the suffix of the file to indicate it is being processed.
|
void |
setWorkDirectory(java.lang.String s)
Set the work directory.
|
additionalDebug, addStandardMetadata, consumeLocationKey, fileFilterImp, getFileFilterImp, getQuietInterval, oldEnough, olderThanMs, prepareConsumer, processMessages, setFileFilterImp, setQuietInterval
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
public void init() throws CoreException
ComponentLifecycle
Component initialisation includes config verification, creation of connections etc.
init
in interface ComponentLifecycle
init
in class FtpConsumerImpl
CoreException
- wrapping any underlying Exception
sComponentLifecycle.init()
protected java.lang.String configureWorkDir(java.lang.String path)
configureWorkDir
in class FtpConsumerImpl
protected boolean accept(java.lang.String path) throws java.lang.Exception
accept
in class FtpConsumerImpl
java.lang.Exception
protected boolean fetchAndProcess(java.lang.String fullPath) throws java.lang.Exception
fetchAndProcess
in class FtpConsumerImpl
java.lang.Exception
public java.lang.String getProcDirectory()
public java.lang.String getWorkDirectory()
public void setProcDirectory(java.lang.String s)
If set, then after downloading the file, it is renamed to this directory, otherwise it is deleted.
If the ConsumeDestination specifies a URL, then it is assumed be a sub-directory of the path specified by the URL. If the ConsumeDestination does not specify a URL, then it is an absolute path.
s
- the directorypublic void setWorkDirectory(java.lang.String s)
If the ConsumeDestination specifies a URL, then it is assumed be a sub-directory of the path specified by the URL. If the ConsumeDestination does not specify a URL, then it is an absolute path.
s
- the directory.ConsumeDestination
public java.lang.String getWipSuffix()
public void setWipSuffix(java.lang.String s)
The first action performed by the consumer is to attempt to rename any file that it is attempting to process to mark it as being processed. This will allow multiple consumers to poll the same directory, and also isolate the consumer from anything that attempts to write to the file concurrently.
s
- The wipSuffix to set, default is "_wip" if not specified.