title: Record processing by multiple instance application by zookeeper
body: <p>I have a micro-service application which has scheduler to pick data from DB based on <code>isProcessed=false</code> flag . It runs continuously every 1 second and polls 50 records at a time. On successful read and after processing it updates value of rows to <code>isProcessed=true</code> . I am using JDBC select and update to perform DB operation on application .</p>
  <p>Currently I am running a single instance of application and if I want to run multiple instances of micro-service it will be race condition in rows of DB . Multiple instances of application polls same  rows and update twice . How to avoid multiple poll of same record in multi instance application .</p>
  <p>Is there any way to use <a href="https://zookeeper.apache.org/" rel="nofollow noreferrer">zookeeper</a> to coordinate between multiple instance to have information of picked DB records . In multi instance DB rows read by one instance should be locked and should not be read by other .</p>
  <p>My table looks like ( 1,2,3 is unprocessed and 4,5 is processed and updated)</p>
  <pre><code>---------------------------
  C1 | C2 | C3 | isProcessed
  ----------------------------
  1  | a  | 3  | false
  2  | b  | 3  | false
  3  | c  | 3  | false
  4  | d  | 3  | true
  5  | f  | 3  | true
  </code></pre>
  <p>Running multiple instances will improve my record DB processing performance as multiple instance will work on same DB . How to avoid overlapping/ processing same record via different micro-service.</p>