Hi,
I have a question which might actually be rather dumb: Is it safe to cache EJB3 stubs? Are they thread-safe?
In other words, if I perform a lookup like that:
[pre]
MyBeanLocal myBeanLocal = (MyBeanLocal)ctx.lookup("...blah-blah...");
[/pre]
can I then safely store the [b]myBeanLocal[/b] stub somewhere and let multiple clients access it simultaneously?
I ran a short test on Oracle Application Server 10.1.3.1 with 10 concurrent threads accessing one and the same stub and calling a long-running method on the SLSB. They each managed to obtain a separate instance of the EJB from the pool and the long-running method was able to run in parallel.
But then again, even if the stub can produce different instances of the EJB, this doesn't necessarily mean that it's thread-safe or, even if it is, that it scales well for thousands of users.
Can anybody tell me what the best approach is?
Best regards,
Bisser
[Message sent by forum member 'vesuvius' (vesuvius)]
http://forums.java.net/jive/thread.jspa?messageID=220209