1
我有一個通過JDBC讀取數據的JdbcPollingChannelAdapter。我想讓它手動輪詢(使用commandChannel)。它不應該自動輪詢,並且它應該在我觸發手動輪詢時立即運行。JdbcPollingChannelAdapter:隻手動輪詢數據庫
下面我使用了一個輪詢器,它每24小時運行一次以獲得運行的頻道。因爲Pollers.cronExpression()不需要年份,所以我不能使用不會像Quartz: Cron expression that will never execute那樣激發的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();
}