• Post Reply Bookmark Topic Watch Topic
  • New Topic

Running multiple ejb processes  RSS feed

 
Mike Burnham
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to write an EJB that will be able to invoke multiple EJB's at the same time. I was thinking of invoking the EJB's in multiple threads and storing that in the caller EJB. At some later time a method on the controller EJB will be able to send messages to the EJB's it originally invoked.
Is it possible to implement such a desing using all enterprise java beans or will I need a separate client to "administor" the other EJB's?
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot use threads in J2EE. Trust me, I've tried it.

Your container will throw a ThreadSecurityException. So even though it will compile, at runtime you will find problems.

Without having any idea what you are trying to do, have you considered using a Session Bean to act as a 'proxy' for Entity EJB's. Entity EJB's should be nothing but 'rows in a database'. Why would anyone need to load up a whole bunch of rows from (different?) tables? That's what the database is for... holding rows of data until they're needed.

If you're able to provide a bit more detail on your reasons, there are lots of smarter people than me on this forum.. They can point you in the right directions.
 
Mike Burnham
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the response
The situation I have is that I have multiple session beans listening to a message queue. I want to have and "admin" bean that is invoked from a servlet that will start these session beans listening to the queue.
I would like this "admin" bean to beable to start multiple listener beans and at a later time beable to stop them. I am using EJB 1.1.
The thing I can't figure out is how to start mutliple listener beans from the admin bean using EJB and not using a thread explicitely.
Any help is appreciated.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a very similar situation, and that is why I attempted thread use. I think we have two similar problems. We'd like to be able to thread our beans... because we want to do some asynchronous stuff (non-blocking stuff). A process that might take some time should not drag down a client. So... try using JMS. Now the problem becomes...how do I get these beans to load themselves and start 'listening' on app server startup? I have to write (like you mention) an admin servlet that someone has to think to go to, so that they can 'poke' these beans into existence.

It is really too bad EJB1.1 doesn't include message driven beans, and the ability to do some 'application startup' behaviour, without the need for outside calls into the application. If you are not restricted to EJB1.1, I'd highly recommend looking at EJB2.0, and at least you'll get half of what you want.

If you have a local bookstore that lets you read a book before buying it, or maybe a well funded library, or heck buy the book yourself... WROX's "Professional JMS Programming" has a chapter on integrating EJB1.1 and JMS. The only thing to be warned about is that their example depends on a few proprietary WebLogic classes.. extensions to the J2EE standard. These extensions complete the missing link so that you wouldn't need to code an admin bean to start the other beans listening. The startup class would do that. It's a great solution, but unfortunately, only for those using WebLogic.

I can only hope iPlanet has something similiar. So far I've been afraid to look.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!