There are 3 ways to do this:

1) Initialize a asynchronous Task Manager in your container startup class
and deposit asynchronous ejb tasks there
2) JMS
3) MessageBeans (found on EJB 2.0)

The first method is the least standardized of the 3 and will require
vendor-specific API (startup class), but is by far the easiest to implement.
The TaskManager is just a simple task queue and a thread that monitors the
queue for tasks, and possibly a thread pool that executes new tasks.  I
whipped up a simple asynchronous TaskManager in Weblogic 5.1 and was doing
asynchronous EJBing in less than 30 minutes.

If you had more time to plan, I would recommend looking into the 2nd or 3rd
option.  However, JMS is only supported by some EJB servers, while
MessageBean is supported only by, AFAIK, Weblogic 5.1 + EJB 2.0 beta patch.

Gene

-----Original Message-----
From: A mailing list for Enterprise JavaBeans development
[mailto:[EMAIL PROTECTED]]On Behalf Of Kaj Bjurman
Sent: Thursday, August 24, 2000 12:41 AM
To: [EMAIL PROTECTED]
Subject: Asynchroneous calls EJB -> EJB


Hi,

Thank you all for the input on my question regarding EJB accessing/using
files...

I have yet another question...
Is it possible to perform an asynchroneous call from an EJB to another EJB.

Lets say that I have a session bean which has the method:
public JobID calculateInterest()

And when that method runs it will call, calculate() on different types of
EJBs. Each type will be able to calculate interest using different
algorithms (and each calculation will be an lengthy operation)

Now I would like to implement calculateInterest as (in pseudo):

public JobID calculateInterest() {
   JobID jobId = ... // get a new id

   //get an array of stateless session beans, which can calculate
   //different types of interest.
   CalculatingBean[] calcBeans = new ......

   //Store jobId and beans in a hashtable or something similar.

   //Now start a thread for each bean
   for (int i=0; i < calcBeans.length; i++) {
      new Thread() {
         public void run() {
            calcBeans[i].calculate();
         }
      }.start();
   }
   return jobId;
}

I know that I can't create Threads, so how do you solve such problem in
EJBs?


/Kaj


Ps.
I know that this might look like an odd problem, but I know that I will have
to solve a similar problem in the near future.


~~~~~~~~~ ~~~~ ~~~ ~~ ~ ~  ~   ~
[EMAIL PROTECTED]
+46 70 4200148

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to