|
如需使用最新稳定版本,请使用 Spring Integration 7.0.4! |
使用 MessageSessionCallback
从 Spring Integration 4.2 开始,您可以使用 MessageSessionCallback<F, T> 实现配合 <int-ftp:outbound-gateway/>(在 Java 中为 FtpOutboundGateway),以利用 requestMessage 上下文对 Session<FTPFile> 执行任何操作。
它可用于任何非标准或低级别的 FTP 操作,并允许从集成流定义和功能接口(Lambda)实现注入中访问,如下例所示:
@Bean
@ServiceActivator(inputChannel = "ftpChannel")
public MessageHandler ftpOutboundGateway(SessionFactory<FTPFile> sessionFactory) {
return new FtpOutboundGateway(sessionFactory,
(session, requestMessage) -> session.list(requestMessage.getPayload()));
}
另一个例子可能是对发送或检索的文件数据进行预处理或后处理。
当使用 XML 配置时,<int-ftp:outbound-gateway/> 提供了一个 session-callback 属性,允许您指定 MessageSessionCallback Bean 的名称。
The session-callback is mutually exclusive with the command and expression attributes.
When configuring with Java, different constructors are available in the FtpOutboundGateway class. |