I have a Java EE application where I require a high performant microservice to consume JMS messages with message driven beans. The service gives out and releases reservations for postal codes and persists these in the database. Since the service should be high performant I want to make it a parallel process.
Giving out reservations for a single postal code could cause race conditions, so this is where I want to avoid parallel reservations on a single postal code. This means I need a lock on only specific reservations, or I need to make sure that my threads will never be accessing the same postal codes at the same time. Either for reserving or releasing reservations.
For the project I MUST use Java EE 7, and I prefer avoiding spring.
What is the best way to go about this, purely relying on JEE7?
Seems like I was taking the wrong approach. A lock on the right JPA entity did the trick.