【问题标题】:Spring Jdbc inbound channel adapterSpring Jdbc 入站通道适配器
【发布时间】:2017-08-01 01:38:18
【问题描述】:

我正在尝试在春季开发一个程序,该程序执行 DB 轮询并选择要读取的记录。我看到了 xml 的示例,但我想知道我们如何在 java config 中进行操作。谁能给我举个例子?

【问题讨论】:

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


    【解决方案1】:

    你需要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

    【讨论】:

    • 好的..但是如何获取该记录进行处理
    • @ServiceActivator 可以让您消费来自fooChannel 的消息:docs.spring.io/spring-integration/docs/4.3.11.RELEASE/reference/…
    • 您好,您能解释一下服务执行器使用 jdbc 记录的方法吗
    • 我猜给定的文档插图不适用于 jdbc
    • 对我来说,我们似乎在谈论不同的语言。 JdbcPollingChannelAdapter@InboundChannelAdapter 一起定期汇集数据库以进行记录并将消息发送到配置的通道。要在该通道中使用这些消息,您应该使用某种业务服务方法声明 @ServiceActivator。请问你猜有什么不对?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-29
    • 2023-03-12
    • 2015-07-11
    • 1970-01-01
    相关资源
    最近更新 更多