spring integration jdbc adapter for multiple nodes

会有一股神秘感。 提交于 2019-12-11 11:19:24

问题


I'm using the jdbc inbound-channel-adapter with a typical configuration as below to retrieve records from MYSQL DB. The question is how to make the jdbc inbound-channel-adapter work in a multiple nodes environment? Different nodes will have chance to get one same record to process. I know this may be a old questions but I cannot find the resolution so far.

<int-jdbc:inbound-channel-adapter query="select * from messages where state='NEW'"
    channel="jdbcChannel" data-source="datasource" update="update messages set state='PROCESSING' where id in (:id)"
    row-mapper="messageRowMapper" max-rows-per-poll="1">
</int-jdbc:inbound-channel-adapter>

回答1:


Yes, you should supply transactions for the <poller> as Gary pointed, but in addition you should guaranty that one transaction will block another until it finishes. For this purpose you should supply your SELECT with FOR UPDATE or LOCK IN SHARE MODE hints.

More info is in MySQL Docs or in this answer: MySQL 'select for update' behaviour .




回答2:


You need to use transactions; also see the appendix about transactions.



来源:https://stackoverflow.com/questions/30098617/spring-integration-jdbc-adapter-for-multiple-nodes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!