gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-10-31 19:45:08 25 4
gpt4 key购买 nike

如何让 @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();
}

关于java - Spring 集成 Java - 如何使用 @InboundChannelAdapter 检查目录中的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31822570/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com