Spring Jdbc入站通道适配器

时间:2017-08-01 01:38:19

标签: spring spring-mvc spring-boot spring-integration

我正在尝试一个程序,在春天进行数据库轮询并选择要读取的记录。我看到xml的例子,但我想知道我们如何在java配置中做。有人能告诉我一个例子吗?

1 个答案:

答案 0 :(得分:0)

您需要JdbcPollingChannelAdapter @Bean定义,标有@InboundChannelAdapter

@Bean
@InboundChannelAdapter(value = "fooChannel", poller = @Poller(fixedDelay="5000"))
public MessageSource<?> storedProc(DataSource dataSource) {
    return new JdbcPollingChannelAdapter(dataSource, "SELECT * FROM foo where status = 0");
}

http://docs.spring.io/spring-integration/docs/4.3.11.RELEASE/reference/html/overview.html#programming-tips