I have an FTP message source and I want to enable the user to configure the poll frequency through an application.
This is the current configuration of the Inbound channel adapter
@Bean
@InboundChannelAdapter(channel = "fromSmartpath", poller = @Poller(cron = "0 15 8 ? * MON,TUE,WED,THU,FRI,SAT"))
public MessageSource<File> sftpMessageSource() throws SftpException {
SftpInboundFileSynchronizingMessageSource source = new SftpInboundFileSynchronizingMessageSource(
sftpInboundFileSynchronizer());
source.setLocalDirectory(new File(Constants.LOCAL_REPOSITORY_PATH));
source.setAutoCreateLocalDirectory(true);
source.setLocalFilter(new FileSystemPersistentAcceptOnceFileListFilter(metaDataStore(), "metastore"));
return source;
}
My goal is to retrieve the cron expression from the database. Is There a way to achieve this?
Thank you
The cron expression ends up in the
CronTrigger
. You can develop some service which SELECT an expression from DB in itsafterPropertiesSet()
and returns it via getter. Then you declare a@Bean
for theCronTrigger
and call that getter from the service during its definition.The
@Poller
on the@InboundChannelAdapter
has atrigger
option to refer to the existing bean.