• Post Reply Bookmark Topic Watch Topic
  • New Topic

SessionBean waiting on JMS Message

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I encountered the folowing situation at a client:
They have several sessionbeans that send a message to a queue, create a java object, pass it a temporary on which to wait for a reply queue for a reply.
I find this a very weird situation and imho, is something which is implicitly disallowed by the (EJB 1.1) spec which says in sec 18 that an EJB should not try to manage or start a thread (a queue session is a thread) and should not try to open a server socket (i don�t know what teh JMS implementation uses, but i guess it�s something similar to a socket).
Any opinions?
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess I already found the answer to this. It�s quite simple actually. EJB is meant to be highly scalable. A sessionbean waiting for a message would actually block an EJB worker thread (block the tansaction) and the server would rapidly run out of resources (workerthreads in this case) resulting in a deadlock.
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess that there's also the situation whereby the waiting EJB, if being notified asynchronously, could be passivated. Not sure what happens here as the listener might not get fired. On the other hand, perhaps the bean is not passivated because a reference is "live".
Any thoughts?
Simon
 
Peter Reinhardt
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think getting messages asynchronously in an SessionBean would break about every rule in the ejb spec possible.
Honestly, once the method call in a session bean is finished you are not allowed to reference the same instance via a MessageListener Interface (just calls over the remote interface are allowed). Perhaps if you bend the rules a little bit and introduce a Singleton etc. you could make it work. Why not try to solve it with a MDB instead ?

Peter
----------------------
SCJP, SCJD, SCEA, WL7
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!