0

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?

RoyB
  • 3,104
  • 1
  • 16
  • 37
  • Sounds like you want proper isolation levels in the database and make sure that the locking is not too broad to reduce the parallelism. What does your database schema look like? – Kayaman Nov 21 '14 at 11:26
  • Im free to choose my own structure. Im thinking about a single table with these columns: id, postalCode, fromNr, toNr Where fromNr is an integer and toNr is also an integer, these are the reserved ranges. – RoyB Nov 21 '14 at 12:12

1 Answers1

0

Seems like I was taking the wrong approach. A lock on the right JPA entity did the trick.

RoyB
  • 3,104
  • 1
  • 16
  • 37