1

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

4

1 回答 1

1

cron 表达式以CronTrigger. 您可以开发一些服务,从其中的 DB 中选择一个表达式afterPropertiesSet()并通过 getter 返回它。然后,您声明 a@BeanCronTrigger在其定义期间从服务中调用该 getter。

@Polleron@InboundChannelAdapter有一个trigger选项来引用现有的 bean 。

于 2018-11-05T14:44:19.893 回答