users@jersey.java.net

Re: [Jersey] synchronized

From: Craig McClanahan <Craig.McClanahan_at_Sun.COM>
Date: Tue, 19 May 2009 12:53:25 -0700

Felipe Gaúcho wrote:
> Jersey is not synchronized, right ?
>
>
The right way to think about it is that your server application must be
prepared to process requests on multiple threads at once. Jersey is
internally synchronized to the extent needed to protect its *own* data
structures from corruption, but anything in the application that
requires synchronization is your responsibility.

This is not really any different than any Java servlet based web
application, where exactly the same considerations apply.
> It means I need to synchronize all my methods with concurrent calls?
>
> Does it create a lot of bottlenecks in the system ?
>
> * I am interested in the calls to the persistence layer, because I got
> this issue:
>
>
> Internal Exception:
> com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException:
> Duplicate entry '455' for key 1
> Error Code: 1062
> Call: INSERT INTO FPCERTIFICATE (ID, PATH, VERSION, USER_ID) VALUES
> (?, ?, ?, ?) bind => [455, /docs/453/8/cert, 1, 453]
>
>
Whether you need synchronization in the persistence tier depends totally
on what framework you are using, and whether that framework provides any
sort of protection of its own. In a database environment, you also need
to pay attention to transaction boundaries, and which transaction modes
are in use. But, again, none of this is at all specific to using Jersey.

Craig

>
>
>
>