Despite whether the proxy is thread safe or not, you may want to consider
how your app server does its load balancing. Some load balance on EJB Home
lookup, so code like you provided below would cheat the load balancer out of
a chance to work.
Dave
David Brown
Technical Director, Western Operations
GemStone Systems, Inc.
(760)510-2754
[EMAIL PROTECTED]
www.gemstone.com
-----Original Message-----
From: Rich Johns [mailto:[EMAIL PROTECTED]]
Sent: Monday, August 14, 2000 3:58 PM
To: [EMAIL PROTECTED]
Subject: Re: Is a Proxy is thread-safe? - Summary
Thanks Tibo, but through no fault of yours I'm still a little fuzzy.
Let me ask this another way. If a client looks up an EJBHome from JNDI,
can that client give that home to multiple concurrent threads?
EJBFooHome home = jndiLookup("EJBFooHome");
for( int i = 0; i < 100; i++ )
{
new Thread() {
public void run()
{
Foo f = home.create( i );
}
}.start();
}
In the above case, would the ejb container, which I assume is intercepting
the create calls against
home, taking care of synchronization?
What I'm driving at here is this. If the above scenario won't work, then I
can't cache EJBHome
object and dole it out to multiple concurrent threads. Right?
Thanks. (Sorry, I keep waiting for the light to go on)
Thibault Cuvillier wrote:
> Rich,
>
> I did not found anywhere in the J2EE/RMI spec that a proxy has to be
> multi-thread safe. I speak about the PROXY, not the remote object (which
is
> multi-thread safe according to the J2EE spec). This point was confirmed by
> Chris Raber who is a trustable guy !
>
> So, if you share a proxy between multiple threads in a client, you must
> synchronize the proxy by wraping it in a synchronized smart proxy.
>
> The Synchronized smart proxy and the linked proxy can be stored in a cache
> to avoid to many JNDI calls.
>
> You can face this situation if a servlet/JSP cache the proxy to the Home
> objects, because each user request will start a new thread. Most of the
> systems do not synchronize the cached proxies on a Home, and it looks to
> work anyway.....
>
> If more than one client get a proxy to the remote object, there is no
> problem, because each client will use it's own proxy instance and server
> connection.
>
> This is what I understood from this discussion.
>
> Tibo.
>
> > -----Original Message-----
> > From: Rich Johns [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, August 14, 2000 3:17 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: Is a Proxy is thread-safe? - Summary
> >
> >
> > Hi Tibo,
> >
> > What is the conclusion of this question? Is it really true,
> > that if you
> > cache EJBHome objects, you must synchronize them? I thought
> > the ejb container handled that?
> >
> > If multiple clients grab the same EJBHome object from JNDI and
> > all use it simulataneously, the container must be at work managing
> > thread saftey. Or, is it the case that each client gets its own stub,
> > which is what allows the thread saftey.
> >
> > If you have an understanding of this, could you please explain this.
> > I've just completed a design where I was planning to cache EJBHomes
> > and now I'm not sure.
> >
> > thanks very much.
> >
>
> [cut to save bandwidth !]
>
>
===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff EJB-INTEREST". For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".