Bob,

Great, thanks a lot, it's a pure java solution and is working fine.

It's clear that if i would like to preserve other sessions trying to do the 
same, i should use a global object, in this case, could i use the ClickServlet 
or something like that ?

Hans

----- "Bob Schellink" <[email protected]> escribió:

> 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

-- 
Hans Poo, WeLinux S.A.
Oficina: 697.25.42, Celular: 09-319.93.05
Bombero Ossa # 1010, Santiago

Reply via email to