Remote File Information

从 5.2 版本开始,FtpStreamingMessageSource(FTP Streaming Inbound Channel Adapter)、FtpInboundFileSynchronizingMessageSource(FTP Inbound Channel Adapter) 和 FtpOutboundGateway(FTP Outbound Gateway) 的“读取”命令在要生成的消息中提供了其他标头来提供有关远程文件的信息:

Starting with version 5.2, the FtpStreamingMessageSource (FTP Streaming Inbound Channel Adapter), FtpInboundFileSynchronizingMessageSource (FTP Inbound Channel Adapter) and "read"-commands of the FtpOutboundGateway (FTP 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.

由于 FtpInboundFileSynchronizingMessageSource 不是针对远程文件生成消息,而是使用本地副本,因此 AbstractInboundFileSynchronizer 在同步操作期间以 URI 样式(protocol://host:port/remoteDirectory#remoteFileName)将远程文件信息存储在 MetadataStore(可在外部配置)中。当轮询本地文件时,FtpInboundFileSynchronizingMessageSource 会检索这些元数据。当本地文件被删除时,建议删除其元数据条目。AbstractInboundFileSynchronizer 提供了一个 removeRemoteFileMetadata() 回调用于此目的。此外,还有一个 setMetadataStorePrefix() 要在元数据键中使用。当这些组件共享同一个 MetadataStore 实例时,建议此前缀不同于 MetadataStore 基础的 FileListFilter 实现中所用的前缀,以避免条目覆盖,因为筛选器和 AbstractInboundFileSynchronizer 都使用相同的本地文件名作为元数据条目键。

Since the FtpInboundFileSynchronizingMessageSource 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 FtpInboundFileSynchronizingMessageSource 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.