How to interrupt a bean?

Discussions

EJB programming & troubleshooting: How to interrupt a bean?

  1. How to interrupt a bean? (3 messages)

    I need such a stateless session bean:
      At the beginning, I send a "start" command to EJB server, and EJB server creates an instance of the bean and the instance start to do a long process. After a while, I may want to stop that process, which means, I want to send a "stop" command to that instance to stop it, in other words, I want to interrupt that instance. How can I send the "stop" command to the running instance?

      Thank you

    Threaded Messages (3)

  2. How to interrupt a bean?[ Go to top ]

    You don't. The server will not allow concurrent access to the bean. You should not put long running processes such as this inside an EJB.

    What is it you are trying to do?
  3. How to interrupt a bean?[ Go to top ]

    i think, to start your ejb, you have to use messaging, because if you use a session bean, the thread will not return to the caller if the server keeps working.
    To stop, you can let your server ejb ask another ejb from time to time: do i have to stop? And the client can send "stop" to that central point.
    I've never tried it, it's just an idea.
  4. How to interrupt a bean?[ Go to top ]

    Hello.
    One method is to check for a condition inside your EJBs doings.That condition could be a field in the database.Being in the database, a call to a bean (other than that involved in your long blocking call) can modify it.Then the bean that is doing the processing could exit.I might say that you should set up the read/write mechanism in order to avoid dirty reads or every kind of problems involved when threads are accessing shared data.