File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to create multiple instances of session EJB

 
MichaelOConnor25
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
Ranch Hand
Posts: 3892
5
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic