title: Lock on object's field value
body: <p>My microservice is receiving messages from a rabbitMQ and storing it on CouchDB,
  I am creating multiple consumers thread to process them, and my code throws ConflictUpdateException because of the race condition which is occurring i.e. </p>
  
  <blockquote>
    <p>Thread X, Y read couch db value for the same Object at the same time; Thread X updates the record in Couch before Thread Y, but Thread Y
    is updating the record on basis of the hash value(_rev) before X 
    modified record.</p>
  </blockquote>
  
  <p>Object's Unique Identifier is composite: name+age+id,</p>
  
  <blockquote>
    <p>How can execute a critical section only for threads with same
    (name+age+id) ?</p>
  </blockquote>
  
  <p>Possible ways I don't want to implement:</p>
  
  <ol>
  <li><p>lock on String value(name + age + id). 
  [as not a good practice]</p></li>
  <li><p>HashMap of String and CustomObjects for locking. 
  [as i don't have a memory bound on count of unique Object]</p></li>
  </ol>
  
  <p>Any suggestions?</p>