We have a requirement in which the problem can be narrowed down as.
- There are several keys, and each key is mapped to an integer.
- When the key is received on the JVM, you need to get the int value from the shared memory, increase it, and then put the increased value back into the shared memory.
Therefore, when two JVMs or two threads read the same value, the update of one of them must be interrupted sequentially so that you do not lose any increment performed by any thread on any of the JVMs.
After the update fails, you read from the shared memory again, increase it and then update until the update is successful, or you have not exhausted the number of "N" attempts.
We are currently using infinispan with optimistic locking, but the behavior is incompatible. Please find a link to this topic.
https://developer.jboss.org/message/914490
Is there any other technology that is well suited to this requirement.
source share