java Spring Integration的JDBC入站通道适配器是否轮询添加到表中的新记录?

wyyhbhjk  于 2023-02-11  发布在  Java
关注(0)|答案(1)|浏览(143)

我已经编写了jdbcinboud通道适配器如下。我正在使用更新查询。但它不工作。查询检索两行,但更新语句没有设置这两行的accType为'P'。请告知

<int-jdbc:inbound-channel-adapter id="jdbcInbound"
          channel="channel"
          data-source="dataSource"
          query="SELECT id, acct_nam FROM Accounts where accType ='N'"       
          update="update Accounts set accType='P' where ID in (:id)        
          row-mapper="AccountRowMapper"
          max-rows-per-poll="100">
    <int:poller fixed-rate="1000"/>
</int-jdbc:inbound-channel-adapter>
frebpwbc

frebpwbc1#

它确实在每个轮询周期调用query="SELECT * FROM Accounts",并提取100行,在您的情况下,这些可能只是第一个100,因为没有其他条件要过滤掉。
一般来说,执行一个没有任何WHERE的公共SELECT是不好的做法。
可以看到,有一个update属性要对刚拉出来的行执行,您的SELECT必须使用WHERE进行调整,以便只接受那些以前没有更新过的行。
更多信息请参见文档:https://docs.spring.io/spring-integration/reference/html/jdbc.html#jdbc-inbound-channel-adapter

相关问题