Re: Tecnic of synchronization for Servers RMI
Erez Katz <[email protected]> Sun, 13 Aug 2006 08:36:45 -0700
| Newsgroups | gmane.comp.java.sun.rmi |
|---|---|
| Message-ID | <[email protected]> |
Paulo,
You need to rethink why you need to synchronize the
remote methods, because they will allow only one
thread at a time to access the remote object. This is
why your performence goes down - only one client can
use your server at the time.
You need to find out exactly which classes should have
synchronized methods.
In your example, the RMI object is like the front gate
to a building, with many rooms in it. Right now you
are allowing one person at a time to enter the
building, instead of one person at a time enter
specific rooms.
Why not remove the "synchronized" keyword from the
remote object itself and do something like this:
public int gravar(UGTO ug) throws RemoteException {
int iRetorno = 0;
SessionPool.getInstancia().createSession(Thread.currentThread().getId());
try{
IUGBBuisness XYZ = getUGBusiness();
synchronized(XYZ)
{
iRetorno = XYZ.gravar(ug);
}
Hope it helps,
Erez Katz
--- Paulo Melo <[email protected]> wrote:
> Hello Guys! I'm with problem os synchronization in
> my Facade(service RMI). My Facade are like Session
> Facade(EJB) and they publish the remote method's.
> The problem is that if I synchronize the method, he
> lock my others object's. My architecture is:
>
> GUI --> Delegate --------------RMI---------------
> Facade --> Bussines -->DAO.
>
> So, when i call the folowing method, for example:
>
> public synchronized int gravar(UGTO ug) throws
> RemoteException {
> int iRetorno = 0;
>
>
SessionPool.getInstancia().createSession(Thread.currentThread().getId());
>
> try{
> iRetorno = getUGBusiness().gravar(ug);
>
>
>
SessionPool.getInstancia().finalizaSecao(Thread.currentThread().getId(),
> Session.Finalizar.SUCESSO);
> } catch(WorkflowException e){
>
>
SessionPool.getInstancia().finalizaSecao(Thread.currentThread().getId(),
> Session.Finalizar.FALHA);
> throw e;
> } finally {
>
>
SessionPool.getInstancia().removeSession(Thread.currentThread().getId());
> }
>
> return iRetorno;
> }
>
> I lock all synchronized method's and lose
> performance )-: ... So the question is: Exist some
> technique or pattern that solve this?
>
> Thankx!!
>
> Obs.: Sorry for my english.
>
> A Paz!!
> Paulo Henrique
>
>
> ---------------------------------
> Novidade no Yahoo! Mail: receba alertas de novas
> mensagens no seu celular. Registre seu aparelho
> agora!
>
>
===========================================================================
> To unsubscribe, send email to [email protected]
> and include in the body
> of the message "signoff RMI-USERS". For general
> help, send email to
> [email protected] and include in the body of the
> message "help".
>
> For a list of frequently asked RMI questions please
> refer to:
> http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html
>
> To view past RMI-USERS postings, please see:
> http://archives.java.sun.com/archives/rmi-users.html
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff RMI-USERS". For general help, send email to
[email protected] and include in the body of the message "help".
For a list of frequently asked RMI questions please refer to:
http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html
To view past RMI-USERS postings, please see:
http://archives.java.sun.com/archives/rmi-users.html