multiple java spring app instances accessing the same DB resources
<p>In my database, i have many records of a certain table that need to be processed from time to time by my java spring app. 
There is a boolean flag, on each row of that table saying whether a given record is currently being processed. </p>

<p>What I'm looking at is having my java spring app deployed multiple times on different servers, all accessing the same shared DB, the same app duplicated with some load balancer, etc. </p>

<p>But only one java app instance at a time can process a given DB record of that particular table. </p>

<p>What are the different approaches to enforce that constraint?</p>

<p>I can think of some unique queue that would dispatch those processing tasks to different java running instances making sure that the same DB record is not processed simultaneously by two different java instances. But that sounds quite complicated for what it is. Maybe there is something simpler? Anything else? Thanks in advance. </p>