0

How can I set a lock in a column (field) in DB using Spring Integration (XML) using jdbc-inbound-adapter?

The reason is to avoid concurrency problems while multiple processes are accessing the same db.

Eddy Bayonne
  • 2,448
  • 1
  • 17
  • 23

1 Answers1

2

What you need is out of Spring Integration responsibly and it is called SELECT ... FOR UPDATE. See answer here: When to use SELECT ... FOR UPDATE?

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • I was thinking that JDBCLockRegistry is to deal with this kind of problems. – Eddy Bayonne May 13 '18 at 13:48
  • 1
    Well, it may do that, but it’s going to be overhead. The solution won’t be so simple for the JDBC Inbound Channel Adapter and there are going to be too much DB operations. Plus need to keep in mind transaction model. Well, I would still stick with SELECT FOR UPDATE – Artem Bilan May 13 '18 at 14:04
  • Thank You for the answer @Artem. I followed your advice for using the SELECT FOR UPDATE. Anyway maybe in the future I will try to understand well this topic using Spring Integration. – Eddy Bayonne May 13 '18 at 14:14
  • If you are using PostgreSQL, you can try advisory locks. – Debjit Sep 27 '22 at 21:30