【发布时间】:2017-04-27 09:53:00
【问题描述】:
我有一个通过 JDBC 读取数据的 JdbcPollingChannelAdapter。我想手动进行轮询(使用 commandChannel)。它永远不应该自动轮询,它应该在我触发手动轮询时立即运行。
下面我使用了一个轮询器,它每 24 小时运行一次,以使频道完全运行。我不能使用像Quartz: Cron expression that will never execute 那样从不触发的 cronExpression,因为 Pollers.cronExpression() 不需要一年。
@Bean
public MessageSource<Object> jdbcMessageSource() {
return new JdbcPollingChannelAdapter(this.dataSource, "SELECT...");
}
@Bean
public IntegrationFlow jdbcFlow() {
return IntegrationFlows
.from(jdbcMessageSource(),
spec -> spec.poller(
Pollers.fixedRate(24, TimeUnit.HOURS)))
.handle(System.out::println)
.get();
}
【问题讨论】: