• Post Reply Bookmark Topic Watch Topic
  • New Topic

Concurrency Issue  RSS feed

 
Grishma Dube
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I've got a peculiar problem.

We have a JSP Form, when user enters his data and clicks on the submit button, the system is generating a .dat file (on the server) with the filled up data. When this .dat file is created, an .exe file (written is Fortron) gets executed, which picks up the .dat file and rest of the processing is done in the Fortron.

The problem we are facing is, the JSP system is web based and allowed to have concurrent users. And the Fortron .exe requires that .dat file with a particular name and location. We can not change the name or the location of that file for the users. (Imp : Fortron code is written long back and cannot be changed, this is our client's requirement).

In such a case, if 1 users have submitted his details, the .dat file is generated for him, meanwhile, the .exe picks up the .dat file, another user submits his details and the .dat file is getting overwritten.

Can anyone suggest some alternative??? We have a complete deadlock situation.

TIA

Grishma
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess the only way out might be to make the whole operation asynchronous. The form data is saved by the servlet and placed in some sort of a queue, where all submissions are processed one by one.

Perhaps, a solution using Message Driven EJB's?
 
Grishma Dube
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sonny,

I was thinking of the similar kind of a solution i.e creating a kind of queue. But not able to think of the implemetation of such a queue.

Could you pls elaborate on our suggestion?

TIA

Grishma
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are already using EJB's MDB might be the way to go, but I dont know a whole lot about MDBs, so I wont comment on that.

But in general, one way of doing it could be-

Have a FormInfo object that incapsulates the information submitted by the user on the submission of a form.

Have a 'manager' object that manages a queue (say java.util.Queue) of these FormInfo objects. The servlet creates a FormInfo object from the form submitted, and sends it to the 'manager' object, let us call that method enqueueFormInfo().

This enqueueFormInfo returns immediately after placing the FormInfo object in the queue, and the manager object manages a thread(s) that processes the FormInfo objects in the queue, one by one, writing the dat file and invoking the fortran routine for each one. The thread could check the queue on regular intervals, or get triggered on each call to the enqueueFormInfo method.

There would be some synchronization issues you will have to be careful with.

HTH
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!