my design requires me to write a stateful session bean which will implement jms message listener. Teh stateful bean will bind to a queue and listen for messages. Is it correct to design so and is it implmentable?
- Posted by: Punam Chordia
- Posted on: November 14 2002 00:07 EST
- Can i write a stateful sessionbean implement a messagelistener by Fred Deb on November 14 2002 05:04 EST
- Can i write a stateful sessionbean implement a messagelistener by Tomas Inger on November 14 2002 08:50 EST
- Can i write a stateful sessionbean implement a messagelistener by Web Master on November 14 2002 09:37 EST
You can implement stateful session bean to be synchronous message listener - my understanding.
From a quick look in the specification, I cannot find something saying "you should not" on this point.
However, to me it seems a bit strange and I havn't seen anything like this before. You should be aware for the concept of durable/non-durable when registring the message listener.
Also note that you may end up in a situation when two threads execure your EJB at the same time: Your normal client thread and the thread started by an incoming message.
Although java does not prevent you to have a session bean implementing messageLiListener, the J2EE does not allow multi threading in EJB. and the idea of EJB blocking waiting a message to arrive is not feasible. Look at it this way: EJBs are not guaranteed to exist between method calls depending on the container. If the been is not called for a while it might be passivated.
Read this Article: