How can i get @InboundChannelAdapter
to work with files? something like this:
<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>
but in java?
Something like this:
@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;
}
From other side pay attention, please, to the Spring Integration Java DSL project, using which the same may look like:
@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();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With