• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Threading within EJBs

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
What's that smell? I think this tiny ad may have stepped in something.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic