Remote File Information
从5.2版本开始,SftpStreamingMessageSource
(SFTP Streaming Inbound Channel Adapter)、SftpInboundFileSynchronizingMessageSource
(SFTP Inbound Channel Adapter)和`SftpOutboundGateway`(SFTP Outbound Gateway)的“read”命令在要发送的消息中提供了附加标头,其中包含有关远程文件的的信息:
Starting with version 5.2, the SftpStreamingMessageSource
(SFTP Streaming Inbound Channel Adapter), SftpInboundFileSynchronizingMessageSource
(SFTP Inbound Channel Adapter) and "read"-commands of the SftpOutboundGateway
(SFTP Outbound Gateway) provide additional headers in the message to produce with an information about the remote file:
-
FileHeaders.REMOTE_HOST_PORT
- the host:port pair the remote session has been connected to during file transfer operation; -
FileHeaders.REMOTE_DIRECTORY
- the remote directory the operation has been performed; -
FileHeaders.REMOTE_FILE
- the remote file name; applicable only for single file operations.
由于 SftpInboundFileSynchronizingMessageSource
不是根据远程文件生成消息,而是使用本地副本,因此 AbstractInboundFileSynchronizer
在同步操作期间将有关远程文件的信息存储在 URI 样式(protocol://host:port/remoteDirectory#remoteFileName
)的 MetadataStore
中(可以外部配置)。SftpInboundFileSynchronizingMessageSource
在轮询本地文件时检索此元数据。当本地文件被删除时,建议删除其元数据条目。为此,AbstractInboundFileSynchronizer
提供了一个 removeRemoteFileMetadata()
回调。此外,还有一个 setMetadataStorePrefix()
要用于元数据键中。当这些组件共享同一 MetadataStore
实例时,建议此前缀与基于 MetadataStore
的 FileListFilter
实现中使用的前缀不同,以避免条目覆盖,因为过滤器和 AbstractInboundFileSynchronizer
对元数据条目键使用相同的本地文件名。
Since the SftpInboundFileSynchronizingMessageSource
doesn’t produce messages against remote files, but using a local copy, the AbstractInboundFileSynchronizer
stores an information about remote file in the MetadataStore
(which can be configured externally) in the URI style (protocol://host:port/remoteDirectory#remoteFileName
) during synchronization operation.
This metadata is retrieved by the SftpInboundFileSynchronizingMessageSource
when local file is polled.
When local file is deleted, it is recommended to remove its metadata entry.
The AbstractInboundFileSynchronizer
provides a removeRemoteFileMetadata()
callback for this purpose.
In addition, there is a setMetadataStorePrefix()
to be used in the metadata keys.
It is recommended to have this prefix be different from the one used in the MetadataStore
-based FileListFilter
implementations, when the same MetadataStore
instance is shared between these components, to avoid entry overriding because both filter and AbstractInboundFileSynchronizer
use the same local file name for the metadata entry key.