|
如需使用最新稳定版本,请使用 Spring Integration 7.0.4! |
消息会话回调
从 Spring Integration 4.2 版本开始,您可以使用 MessageSessionCallback<F, T> 实现配合 <int-sftp:outbound-gateway/>(SftpOutboundGateway)在 Session<SftpClient.DirEntry> 上执行任何操作,并使用 requestMessage 上下文。
您可以将其用于任何非标准或底层的 SFTP 操作(或多个操作),例如允许从集成流定义或函数式接口(lambda)实现注入中访问。
以下示例使用了 lambda:
@Bean
@ServiceActivator(inputChannel = "sftpChannel")
public MessageHandler sftpOutboundGateway(SessionFactory<SftpClient.DirEntry> sessionFactory) {
return new SftpOutboundGateway(sessionFactory,
(session, requestMessage) -> session.list(requestMessage.getPayload()));
}
另一个例子可能是对发送或检索的文件数据进行预处理或后处理。
当使用 XML 配置时,<int-sftp:outbound-gateway/> 提供了一个 session-callback 属性,允许您指定 MessageSessionCallback Bean 的名称。
The session-callback is mutually exclusive with the command and expression attributes.
When configuring with Java, the SftpOutboundGateway class offers different constructors. |