Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

How to create multiple instances of session EJB

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am learning WSAD 4.0.3.
I have a stateless session EJB. I can run the test client in WSAD and use the JNDI lookup to call the create method and then access my EJB.
However when I invoke the create method again I do not get a second instance.
How can I get it to create a 2nd instance of my EJB?
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ummm...Stateless beans are pooled. That's what stateless means. WHY would you want to create a second instance? What are you trying to do? It seems to me you're not quite clear on how session EJB's work...
Kyle
 
MichaelOConnor25
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bascially, load balancing -
I'm trying to write a EJB which serves as an interface to a bank of CORBA servers.
The CORBA servers are instances of the same application running on different machines, each of which is single threaded. The calls are synchronous so the calling code gets blocked until the request finishes.
My idea was to have multiple instances of a session EJB. Each, when it is invoked, chooses the next CORBA server to invoke on.
Do you think this is wrong approach altogether and I should just have 1 multithreaded session EJB?
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, the EJB is already multithreaded and load balanced if it's a stateless session EJB. So just try this:
Build a stateless EJB that on each call to the EJB RANDOMLY picks a server out of the list of CORBA servers and sends a request to it. That particular EJB thread will block on that CORBA call, yes, but that's OK -- the EJB is stateless, so the other threads in the thread pool will continue to run other "copies" of that method servicing other servers the whole time...
Kyle
 
reply
    Bookmark Topic Watch Topic
  • New Topic