Created
August 28, 2020 17:57
-
-
Save iainporter/c350ec6b61289290a72a20845c05ca80 to your computer and use it in GitHub Desktop.
DSL spring integration flow for polling for files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Bean | |
public IntegrationFlow inboundFileIntegration(@Value("${inbound.file.poller.fixed.delay}") long period, | |
@Value("${inbound.file.poller.max.messages.per.poll}") int maxMessagesPerPoll, | |
TaskExecutor taskExecutor, | |
MessageSource<File> fileReadingMessageSource) { | |
return IntegrationFlows.from(fileReadingMessageSource, | |
c -> c.poller(Pollers.fixedDelay(period) | |
.taskExecutor(taskExecutor) | |
.maxMessagesPerPoll(maxMessagesPerPoll) | |
.transactionSynchronizationFactory(transactionSynchronizationFactory()) | |
.transactional(transactionManager()))) | |
.transform(Files.toStringTransformer()) | |
.channel(ApplicationConfiguration.INBOUND_CHANNEL) | |
.get(); | |
} | |
@Bean | |
TaskExecutor taskExecutor(@Value("${inbound.file.poller.thread.pool.size}") int poolSize) { | |
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor(); | |
taskExecutor.setCorePoolSize(poolSize); | |
return taskExecutor; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment