1. Have the SLSB start a new thread that processes the data. This would allow the bean to return and the client to get back to doing what it was doing. However, I have been told on more then one occasion that starting my own threads inside an application server is not a good idea.
You can�t do that Chris. Your application might start a new thread, but not inside of an EJB. The EJB container was designed to associate one bean instance with exactly one execution thread. If your EJB calls Runnable.start() then another thread will start, the instance will go back to pool, and before the thread finishes, another client (or the same client) might get the same bean instance from the pool and start a new execution thread. At this point you�ll have two execution threads associated with the same bean instance; this will break your container. However there are other techniques for starting new threads (which as you said are not good practice), using startup classes, or using
servlets with load on startup flag set to on. Asynchronous message processing was one of the reasons to employee these techniques, before EJB 2.0; but not many reasons to do it these days...
2. Make the client multi-threaded so that is can connect to more then one bean.
Back to your SLSB that processes the data and returns after a while. Following your design the client will start a new thread that calls the bean asynchronously. The client doesn�t wait anymore but the container will start a new transaction and will reserve a bean instance during that transaction. The problem here is that the client can do this all over again (since s/he doesn�t need to wait) and you might have more client requests than bean instances in the pool; the extra requests will be blocked until some of them become available. If no bean gets available before the transaction expires, then the container will throw a transaction time out exception. How will you handle this exception? If client A sends two asynchronous request R1 and R2, R1 succeeds but R2 fails, how can you notify the client that the first request succeeded and the second failed and not vice versa? Finally you might need to come up with a scenario to overcome these problems and you might end up implementing a more complex solution than using JMS.
Regards.