Hi, 

I have managed to get myself confused over when to use Stateless Session Beans 
versus just making calls to static methods.  I know there's lots of 
documentation about when to use Session Beans, but I haven't found anything 
discussing this particular comparison.  I'm hoping someone can help me get my 
head around this because I'm pretty new to J2EE.  Thanks.

I am working on a middleware system that basically routes messages between 
several applications state-wide, and indirectly nation-wide.  I wanted to write 
two classes.  One  uses Hibernate to store each message in the database as it 
passes through the middleware.  Then when all the responses for a request come 
in, this class will pass the message bundle to my second class, a router.  The 
router class is meant to do some minor security and then send the message 
bundle off to the proper destination.  I had originally thought these two 
classes would just be Stateless Session Beans that would be invoked from an MDB 
when a new message reaches my JMS Queue.

However, our consultant thought it would be a far better idea to use a class 
with static methods instead of Stateless Session Beans.  Because these classes 
do not have state information, the static approach should work, he said.  The 
static approach would supposedly use less memory because there are no beans 
(other than the MDBs) being pooled, and only one instance would be in memory.  
He claims there will be no concurrency issues because an MDB can still call a 
static method without worry of when the other MDBs call the static method.  
Again, the methods are stateless, and supposedly no MDB would block waiting for 
another MDB to finish (just like how anyone can call System.out.println() 
without worry that some other class called it at the same time).

All of that sounds fairly reasonable, but now I've got myself confused.  With 
this in mind, why does anyone ever use Stateless Session Beans?  I hope that 
doesn't sound accusatory.  I'm certain that Sun know what they're doing!  ;-)  
I'm just confused.  The one benefit is JNDI look-ups, obviously, but if the 
beans are going to be on the same box is there any reason to use the Stateless 
Session Beans?

Please help!  I've gotten myself confused and I'm sure I'm just having a brain 
freeze here.  Anyone who can set me straight would be GREATLY appreciated, so 
that I understand when I should use a Stateless Session Bean, and what the 
trade-offs are for these two approaches.

If I need to better explain anything, just let me know.  I have commercial 
support too, but I hate to bother JBoss with something that is probably so 
obvious to those of you with more experienced.  Thanks!

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3869859#3869859

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3869859


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to