Results 1 to 2 of 2

Thread: Accessing EJBs from user created thread

  1. #1
    Join Date
    Feb 2010
    Location
    Stockholm, Sweden
    Posts
    1

    Question 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

  2. #2
    Join Date
    Apr 2010
    Posts
    8

    Default

    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
  •