Bob Schellink wrote:

The problem is that if i open "more than one document uploading window" and press submit at once, eventually a race condition arise and two documents get registered, breaking the business rule.


Btw it seems as if you want to use Transaction isolation to serialize the upload requests. If that is the case I don't think transactions is the ideal way to solve this. Rather synchronize on the session object: e.g:

  public void processDocument(File file, Context context) {
    HttpSession session = context.getSession();

    // concurrent requests will queue up here
    synchronize(session) {

      validateDocument(file);

    }
  }

The above assumes validation is done by an automatic process. If it requires human intervention or the validation process takes a long time, you might want to think about using asynchronous requests and dumping the documents into a Queue to be processed later.

I'm sure there are many other ways to approach the problem as well.

kind regards

bob

Reply via email to