<int-jdbc:inbound-channel-adapter channel="jdbcInboundChannel"
data-source="dataSource"
max-rows-per-poll="100"
row-mapper="AMapper"
query="select * from A"
update="delete from A">
<int:poller fixed-delay=100 error-channel="ErrorChannel" task-executor="Excutor">
<int:transactional propagation="REQUIRED" transaction-manager="transactionManager"/>
</int:poller>
</int-jdbc:inbound-channel-adapter>
<task:executor id="Excutor" pool-size="10"/>
一开始以为配置了fixed-delay,就万事无忧了,但是发现select出来的一直有重复的。不是说好的处理完上一个任务,再隔100ms才做下一个定时任务吗?因为没找到对fixed-delay定时任务结束标志的文档,所以就简单根据日志总结了一下,主要原因应该是这里的Excutor线程池配置了10个,同时si中的fixed-delay的定时任务结束标志好像并不是jdbc事务的提交,或者不同excutor线程之间是不相互影响的。
查看日志可以看到,不管jdbc的事务有没有提交,无论配置的是fixed-delay还是fixed-rate,每隔100ms,定时任务都会执行,但是是不同线程的excutor,并且每个excutor都能查询到。解决方案就是pool-size配置为1,或者确保jdbc的事务在fixed-delay的时间内能完成,但这样感觉配多个线程好像又没什么意义了。