Spring 集成 Java - 如何使用@InboundChannelAdapter 检查目录中的文件?

Spring integration Java - how to use @InboundChannelAdapter to check a directory for files?

我怎样才能 @InboundChannelAdapter 处理文件?像这样:

<int-file:inbound-channel-adapter id="executionMessageFileInputChannel"
                                      directory="file:${fpml.messages.input}"
                                      prevent-duplicates="false" filename-pattern="*.xml">
        <int:poller fixed-delay="20000" max-messages-per-poll="1" />
</int-file:inbound-channel-adapter>

但在 java?

像这样:

@Bean
@InboundChannelAdapter(value = "executionMessageFileInputChannel",
        poller = @Poller(fixedDelay = "20000", maxMessagesPerPoll = "1"))
public MessageSource<File> fileMessageSource(@Value("${fpml.messages.input}") File directory) {
    FileReadingMessageSource fileReadingMessageSource = new FileReadingMessageSource();
    fileReadingMessageSource.setDirectory(directory);
    fileReadingMessageSource.setFilter(new SimplePatternFileListFilter("*.xml"));
    return fileReadingMessageSource;
}

请从其他方面注意 Spring Integration Java DSL 项目,使用它可能看起来像:

    @Bean
    public IntegrationFlow fileReadingFlow(@Value("${fpml.messages.input}") File directory) {
        return IntegrationFlows
                .from(s -> s.file(directory).patternFilter("*.xml"),
                        e -> e.poller(Pollers.fixedDelay(20000)))
        .....................
                .get();
    }