Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Prevent Multiple Submits

 
Balakrishnan Viswanathan
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I have an application, where in I have multipler servers (used for load-balancing). And the data is maintained in oracle and is pretty huge. As the application is vast, there are many performance-intensive transactions that take even 10 minutes to complete. Recently, we have been having issues where the same operation has been committed by multiple-users. Example,

a.) First user logs in and submits the process
b.) while the transaction is running, another user trys to do the same thing unknowing the fact that it is already running.

I can try preventing this submit, using javascript or even session. But, this being a multi-server architecture, session variable that is present in one server is not visible to the other one.

Can you please suggest me one best way to prevent this problem?

Thanks
Bala
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I can try preventing this submit, using javascript or even session. But, this being a multi-server architecture, session variable that is present in one server is not visible to the other one.


Bala,

I dont understand how one user is so tightly coupled to the other user. Is it clustered servers ? in that case session migration is there and session variable is visible to other servers , but its costly and hence you got to minimize the variables in session.

Javascript ? Do you mean disabling submit . thats not the proper solution for this.



Is that expected behavior ? Check if you use any instance variables , which is shared among threads , hence needs to be synchronized.
 
Naresh Narayana
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it takes that long to complete request, better use a queue for the requests and process each one as they complete.
Hope it helps.
 
Balakrishnan Viswanathan
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.

Actually yes, some times even the user who submitted first assumes that the process is not running correctly and re-submits it again. Or some other user submits the process.
Am not sure whether usage of synchronized will help here and nor the synchronized threads.

Actually, am thinking about a way to load the first user submit details in a xml and when second user submits, use JAXB to identify whether it is present and if present do not do it again.

Any suggestions or improvements?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic