1

我正在使用 sftp 输入适配器和将轮询文件发布到本地,我想读取内容并实现一些逻辑。sftp inbound-channel-adapter 是否有可用的回调功能?我是 spring 新手,所以请分享在成功轮询后处理文件的可用选项。

配置:

<int-sftp:inbound-channel-adapter id="sftpInbondAdapter"
            auto-startup="true"
            channel="receiveChannel"
            session-factory="sftpSessionFactory"
            remote-directory="/home/sftp/source"
            local-directory="file:/home/sftp/target/"
            auto-create-local-directory="true"
            delete-remote-files="false"
            filename-regex=".*\.txt$">
<int:poller fixed-rate="5000" />
</int-sftp:inbound-channel-adapter>  

我没有看到每次轮询文件时都会调用的任何回调方法。目的是在固定间隔后从源轮询文件,读取内容并执行一些逻辑。Java代码片段:

localFileChannel = context.getBean("receiveChannel", PollableChannel.class);

SessionFactory<LsEntry> sessionFactory = context.getBean(CachingSessionFactory.class);

template = new RemoteFileTemplate<LsEntry>(sessionFactory);

SourcePollingChannelAdapter adapter = context.getBean(SourcePollingChannelAdapter.class);
            adapter.start();

Message<?> received = (Message<?>) localFileChannel.receive(1000);
4

0 回答 0