-
Feb 10th, 2010, 02:35 AM
#1
Accessing EJBs from user created thread
Hi,
I'm migrating to Spring and have lots of old EJBs that still needs to be EJBs. For several reasons, I really need the calls to the EJB to be asynchronous, but I find no way to do it.
The call originally comes from the web container (hessian web service), and I have been trying to use TaskExecutor, normal Threads etc, but the container (OC4J) complains that the thread is in a non application context of course.
How can I spawn off threads in Spring that are in the correct (EJB?) context? Or maybe there is a way to have a servlet return immediately?
Best regards
Torbjörn
-
Apr 15th, 2010, 05:58 AM
#2
In general,
it's a good practice to use jms if you want to do asynchronous activities.
This means that:
1. Your servlet sends a message in a queue
2. A Message Driven Bean intercepts the message and, based on its content, may invoke the correct EJB
Another (and probably more scalable) solution may be creating a queue for each session bean, and hence, an mdb for each one.
In order to try both the solutions, I suggest you to implement a service locator on the web tier.
Anyway, you have to cope with eventual return value, which should be persisted somewhere.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules