• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on role of threads in EJB

 
Aarati Manel
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In case of Servlet - if 10 clients are accessing the servlet then there will be only 1 servlet instance and 10 threads get created in the container, which are accessed by 10 clients.

Now In case of EJB- consider 10 clients sending message to JMS Queue and OpenAccountMDB consumes the message and calls the OpenAccountBean session bean method.
Then in this scenario container pulls 10 OpenAccountMDB instances from the pool and creates 10 OpenAccountBean session bean instances.
Then is there any role of threading in EJB ? like Servlet has? What kind of multi threading is taken care by EJB container?

 
Rishi Shehrawat
Ranch Hand
Posts: 218
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The container takes care of threading. In the case of MDB's the number of threads spawned to porcess depend on the configuraiton for consumers. You could have set this value to 1 in case you wanted just one message to be processed at one time & in this case the container would have spawned just one thread.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic