• Post Reply Bookmark Topic Watch Topic
  • New Topic

Threading within EJBs

 
Deepak Ramachandran
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a situation in my application where a process reads a JMS queue and the MDB waiting on the JMS queue calls multiple EJBs and based on the response from these EJBs , makes a decision.

Question is How can I thread the calls to multiple EJBs from within the MDB?

Today this is implemented in C and it uses unix ipc channels as the queue. How does JMS queue compare in performance to unix ipc channels? Is there a better architecture that can be used to handle this situation?

Thanking you in advance.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must not thread the calls to EJBs, the EJB container takes care of this. Indeed, you would quite possibly cause a problem if you attempted threading as this may clash with the container's threads.
 
Deepak Ramachandran
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your reply.
Do you mean to say that...
If i am making 2 ejb calls from an MDB, does it not wait until the first call is completed, to make the second call? I did not quite understand how threading happens automatically within the container..
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The EJB specification requires the EJB container to ensure that:

... only one thread can be executing an instance at any time.


It is up to the provider of the EJB container to comply with this requirement. We don't know how it's done, but what we do know is that every compliant container will do it.

The specification also has some programming restrictions which you should be aware of:

An enterprise bean must not use thread synchronization primitives to synchronize execution of multiple instances.


The enterprise bean must not attempt to manage threads. The enterprise bean must not attempt to start, stop, suspend, or resume a thread, or to change a thread´┐Żs priority or name. The enterprise bean must not attempt to manage thread groups.
 
Kevin Smither
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Roger has stated you must not use threads in an EJB it interferes with the Enterprise Container's own thread management facilities.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!