此版本仍在开发中,尚未被视为稳定版本。对于最新的稳定版本,请使用 Spring Integration 6.3.1Spring中文文档

此版本仍在开发中,尚未被视为稳定版本。对于最新的稳定版本,请使用 Spring Integration 6.3.1Spring中文文档

V5.2 中添加的 ,侦听某些 Apache Mina SFTP 服务器事件,并将它们发布为 s,任何 bean、bean 方法或事件入站通道适配器都可以接收。ApacheMinaSftpEventListenerApplicationEventApplicationListener@EventListenerSpring中文文档

目前,支持的事件包括:Spring中文文档

它们中的每一个都是 的子类;您可以配置单个侦听器来接收所有事件类型。 每个事件的属性是 ,从中可以获取客户端地址等信息;在抽象事件上提供了一种方便的方法。ApacheMinaSftpEventsourceServerSessiongetSession()Spring中文文档

要使用侦听器(必须是 Spring bean)配置服务器,只需将其添加到:SftpSubsystemFactorySpring中文文档

server = SshServer.setUpDefaultServer();
...
SftpSubsystemFactory sftpFactory = new SftpSubsystemFactory();
sftpFactory.addSftpEventListener(apacheMinaSftpEventListenerBean);
...

要使用 Spring Integration 事件适配器使用这些事件,请执行以下操作:Spring中文文档

@Bean
public ApplicationEventListeningMessageProducer eventsAdapter() {
    ApplicationEventListeningMessageProducer producer =
        new ApplicationEventListeningMessageProducer();
    producer.setEventTypes(ApacheMinaSftpEvent.class);
    producer.setOutputChannel(eventChannel());
    return producer;
}