Skip to content

Instantly share code, notes, and snippets.

@iainporter
Created August 28, 2020 17:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iainporter/c350ec6b61289290a72a20845c05ca80 to your computer and use it in GitHub Desktop.
Save iainporter/c350ec6b61289290a72a20845c05ca80 to your computer and use it in GitHub Desktop.
DSL spring integration flow for polling for files
@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