2017-04-27 8 views
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(); 
} 

答えて

1

さて、あなたは正しい方法についてJdbcPollingChannelAdaptercommandChannelを行くが、あなたはそのIntegrationFlows.from(jdbcMessageSource()と同じように、あなたは、configure SourcePollingChannelAdapterを持っていません。あなたが本当にjdbcMessageSource()である必要がありますが、手動でコマンドベースのフローを設定する必要があり、それをポーリングするためにどのような

:まさにそのがタイミング的にSourcePollingChannelAdapterから呼び出され

@Bean 
public IntegrationFlow jdbcFlow() { 
    return IntegrationFlows 
      .from("commandChannel") 
      .handle(jdbcMessageSource(), "receive") 
      .handle(System.out::println) 
      .get(); 
} 

関連する問題