jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes Multiple Instance of App server- threading issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Multiple Instance of App server- threading issue" Watch "Multiple Instance of App server- threading issue" New topic

Multiple Instance of App server- threading issue

deenbandhu prasad

Joined: Feb 21, 2008
Posts: 9
The application architecture - We have 2 application server(NOn clustered environment) with the same application , both the application server pointing to the single database.

Service : we have service which reads the database and check for the entity and if that entity is not present its adds it to the database and if it is present it will update the entity.

Problem : we have multiple threads running simultaneously to through the 2 application server. Both at the same time reads the Database and find that the entity is not present. Both thread adds the same entity in the Database. and we have duplicate rows.

The primary key and entity are different so the database doesn't restrict the duplicate rows.

Ques :
By making code thread safe by using synchronized, will it prevent the above problem ? I doubt that as we have 2 application server running on different JVM. How to prevent the above problem ? thanks in advance
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Multiple Instance of App server- threading issue
It's not a secret anymore!