@ComponentProfile(summary="Put a file on a FTP/SFTP server; uses PUT, RNFR and RNTO for atomicity", tag="producer,ftp,ftps,sftp", recommended=FileTransferConnection.class) public class FtpProducer extends RequestReplyProducerImp
The connection type for this implementation should always be a concrete subclass of FileTransferConnection
such as
FtpConnection
or SftpConnection
The destination returned by the ProduceDestination implementation should be in the URL form dictated by the
FileTransferConnection
flavour or simply the IP Address / DNS name of the FTP/SFTP Server. If the URL form is used,
then it is possible to override the username, password, and port settings of the FTP server, in all other cases the configuration
specified in the FileTransferConnection
object will be used.
The output filename is controlled using the standard FileNameCreator interface. The AdaptrisMessage object is first uploaded to the build-directory and subsequently renamed into the dest-directory. In most FTP Server implementations, the rename can be considered an atomic operation, so using this method reduces the liklehood of file read attempts during the upload.
It is possible to perform limited request retry functionality using this implementation, in this instance
reply-directory
element must be set. We strongly discourage anyone else from trying to implement request reply
using FTP, it is dangerous and prone to undefined behaviour.
When running in request reply mode, the following steps occur after producing the file in the normal fashion.
reply-directory
reply-proc-directory
is set, then move the file to this directory, otherwise delete it
In the situation where a specific file should be treated as the reply, then the metadata key corresponding to
CoreConstants#FTP_REPLYTO_NAME
should be populated.
FileNameCreator
,
FtpConnection
,
FileTransferConnection
,
ProduceDestination
In the adapter configuration file this class is aliased as ftp-producer which is the preferred alternative to the fully qualified classname when building your configuration.
log
Constructor and Description |
---|
FtpProducer()
Default Constructor with the following defaults.
|
Modifier and Type | Method and Description |
---|---|
protected long |
defaultTimeout()
The default is 1 minute (60000 ms).
|
void |
doProduce(AdaptrisMessage msg,
java.lang.String endpoint)
Actually do the produce.
|
protected AdaptrisMessage |
doRequest(AdaptrisMessage msg,
java.lang.String endpoint,
long timeout)
Actually do the request.
|
java.lang.String |
endpoint(AdaptrisMessage msg)
Return the endpoint that will be derived from the message.
|
java.lang.String |
getBuildDirectory()
Get the build directory.
|
java.lang.String |
getDestDirectory()
Get the destination directory.
|
ProduceDestination |
getDestination()
Deprecated.
|
FileNameCreator |
getFilenameCreator() |
java.lang.String |
getFtpEndpoint()
The FTP endpoint in which to deposit files.
|
java.lang.String |
getReplyDirectory()
Deprecated.
|
java.lang.String |
getReplyProcDirectory()
Deprecated.
|
java.lang.Boolean |
getReplyUsesEncoder()
Deprecated.
|
void |
init()
Initialises the component.
|
void |
prepare()
Prepare for initialisation.
|
boolean |
replyUsesEncoder()
Deprecated.
|
void |
setBuildDirectory(java.lang.String string)
Set the build directory.
|
void |
setDestDirectory(java.lang.String string)
Set the dest directory.
|
void |
setDestination(ProduceDestination destination)
Deprecated.
|
void |
setFilenameCreator(FileNameCreator creator) |
void |
setFtpEndpoint(java.lang.String ftpEndpoint)
The FTP endpoint in which to deposit files.
|
void |
setReplyDirectory(java.lang.String replyDirectory)
Deprecated.
|
void |
setReplyProcDirectory(java.lang.String replyProcDirectory)
Deprecated.
|
void |
setReplyUsesEncoder(java.lang.Boolean replyUsesEncoder)
Deprecated.
|
produce, produce, request, request, request, request
copyReplyContents, getIgnoreReplyMetadata, mergeReply, setIgnoreReplyMetadata
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
close, start, stop
createQualifier, isTrackingEndpoint
public FtpProducer()
public void init() throws CoreException
ComponentLifecycle
Component initialisation includes config verification, creation of connections etc.
CoreException
- wrapping any underlying Exception
sComponentLifecycle.init()
protected long defaultTimeout()
defaultTimeout
in class RequestReplyProducerBase
RequestReplyProducerBase.defaultTimeout()
public void doProduce(AdaptrisMessage msg, java.lang.String endpoint) throws ProduceException
RequestReplyProducerImp
doProduce
in class RequestReplyProducerImp
ProduceException
protected AdaptrisMessage doRequest(AdaptrisMessage msg, java.lang.String endpoint, long timeout) throws ProduceException
RequestReplyProducerImp
doRequest
in class RequestReplyProducerImp
ProduceException
public void prepare() throws CoreException
ComponentLifecycleExtension
CoreException
public java.lang.String getBuildDirectory()
public java.lang.String getDestDirectory()
public void setBuildDirectory(java.lang.String string)
string
- the dir.public void setDestDirectory(java.lang.String string)
string
- the dir.@Deprecated @Removal(version="4.0.0") public boolean replyUsesEncoder()
public FileNameCreator getFilenameCreator()
public void setFilenameCreator(FileNameCreator creator)
public java.lang.String endpoint(AdaptrisMessage msg) throws ProduceException
AdaptrisMessageProducerImp
The purpose of this method is to mitigate the number of changes that need to happen because
ProduceDestination
is being deprecated; boilerplate code can still be present in the
parent super-classes w/o impacting concrete sub-classes "too much".
endpoint
in class AdaptrisMessageProducerImp
ProduceException
AdaptrisMessageProducer.request(AdaptrisMessage, ProduceDestination)
,
AdaptrisMessageProducer.request(AdaptrisMessage, ProduceDestination, long)
,
AdaptrisMessageSender.produce(AdaptrisMessage)
,
AdaptrisMessageSender.produce(AdaptrisMessage, ProduceDestination)
@Deprecated public java.lang.String getReplyDirectory()
This is a legacy feature that was enabled for certain customers that thought it would be a really good idea to try and do request reply via FTP.
@Deprecated public void setReplyDirectory(java.lang.String replyDirectory)
This is a legacy feature that was enabled for certain customers that thought it would be a really good idea to try and do request reply via FTP.
@Deprecated public java.lang.String getReplyProcDirectory()
This is a legacy feature that was enabled for certain customers that thought it would be a really good idea to try and do request reply via FTP.
@Deprecated public void setReplyProcDirectory(java.lang.String replyProcDirectory)
This is a legacy feature that was enabled for certain customers that thought it would be a really good idea to try and do request reply via FTP.
@Deprecated public java.lang.Boolean getReplyUsesEncoder()
This is a legacy feature that was enabled for certain customers that thought it would be a really good idea to try and do request reply via FTP.
The default is true, because otherwise how else can you transfer metadata?
@Deprecated public void setReplyUsesEncoder(java.lang.Boolean replyUsesEncoder)
This is a legacy feature that was enabled for certain customers that thought it would be a really good idea to try and do request reply via FTP.
The default is true, because otherwise how else can you transfer metadata?
@Deprecated public ProduceDestination getDestination()
@Deprecated public void setDestination(ProduceDestination 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. The destination directory will be /work
ftp://10.0.0.1/path/to/dir
, the username and password will be taken
from the corresponding connection. The destination directory will be
/path/to/dir/work
ftp://user:password@10.0.0.1/path/to/dir
.
The destination directory will be /path/to/dir/work
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. The destination directory will be /work
ftp://10.0.0.1/path/to/dir
, the username and password will be taken
from the corresponding connection. The destination directory will be
/path/to/dir/work
ftp://user:password@10.0.0.1/path/to/dir
.
The destination directory will be /path/to/dir/work