1

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>
Xianbo
  • 13
  • 2

2 Answers2

0

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

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
0

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 .

Community
  • 1
  • 1
Artem Bilan
  • 113,505
  • 11
  • 91
  • 118