The ApacheMinaSftpEventListener, added in version 5.2, listens for certain Apache Mina SFTP server events and publishes them as ApplicationEvent s which can be received by any ApplicationListener bean, @EventListener bean method, or Event Inbound Channel Adapter.spring-doc.cn

Currently, supported events are:spring-doc.cn

Each of these is a subclass of ApacheMinaSftpEvent; you can configure a single listener to receive all the event types. The source property of each event is a ServerSession, from which you can obtain information such as the client address; a convenient getSession() method is provided on the abstract event.spring-doc.cn

To configure the server with the listener (which must be a Spring bean), simply add it to the SftpSubsystemFactory:spring-doc.cn

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

To consume these events using a Spring Integration event adapter:spring-doc.cn

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