Hi Anil! If I understood correctly (you need to perform operations on two caches have exclusive lock on personId) then in your case the better way is using Ignite pessimistic transaction:
personCache = ignite.cache("PERSON_CACHE"); detailCache = ignite.cache("DETAIL_CACHE"); try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { // On this step will be acquired lock on personId // and only one thread in grid will execute code bellow. personCache.get(personId); // cache put,remove,invoke and etc. tx.commit(); } Is't work for you? On Thu, Mar 16, 2017 at 3:09 PM, Anil <anilk...@gmail.com> wrote: > Hi, > > I need to make sure that entries are added correctly in two caches. > > I have two caches Person and Detail. personId is the key for Person cache > and detailedId is the key for Detail cache. > > Each Detail cache entry would have some information of Person cache entry > based on personId. and i am adding entries to caches using Kafka. > > When Person and Detail messages are processed, order cannot be maintained > and processed by different nodes. So to avoid data inconsistency issues - i > did following. > > *Person message :* > > Locl lock = personCache.lock(personId); > lock.lock(); > > // update person operations for both person cache and detail cache > > lock.unlock(); > > *Detail Mesage :* > > > Locl lock = detailCache.lock(personId); // person id from detail message > lock.lock(); > > // update person operations for both person cache and detail cache > > lock.unlock(); > > with this, till one of the message processed for same person Id, other > would not acquire lock. > > now how to maintain the ACID for update operations ? ignite transactions > does not work inside lock. Is there anyway to achieve the above usecase > with ACID ? > > Thanks > >