4 Replies Latest reply on May 24, 2003 2:02 PM by juhalindfors

    Asynchronous running/Head scratching?

    robbobkirk

      Apologies if this is a daft question but I'm busy learning about J2EEs and been using JBoss and so far I'm very impressed.
      What I do not yet understand is how I implement a bean that starts up when the application is deployed and for example wakes up every 10 seconds to do something (say just outputs a log line at the moment).

      Any help would be much appreciated!

      Rob

        • 1. Re: Asynchronous running/Head scratching?
          raja05

          There are many ways to do it.
          1) Create a Startup servlet in your application and let it spawn a thread. this thread runs in an infinte loop waking up every 10 secs to output the log line
          2) Create a MBean which gets started after your app is deployed. This class has a startService method(look up the Docs to know the Service lifecycle for mbeans) which spawns a thread that wakes up every 10 secs.

          HTH
          Raj

          • 2. Re: Asynchronous running/Head scratching?
            robbobkirk

            Thanks a lot for the help raja.

            Are there any examples of either of the above, or documents that I can read. I'd read about MBeans but failed to find an example which I find the best way to get started.

            Rob

            • 3. Re: Asynchronous running/Head scratching?
              robbobkirk

              I've managed to get a MBean running and talking to it via JMS- Thanks for the heads up.
              I read that you shouldn't create threads within the J2EE Container but is that only for EJBs?

              • 4. Re: Asynchronous running/Head scratching?

                thats only for EJBs that live inside the container that is supposed to do all this resource management for you

                MBeans in JBoss are more of a system level components, and you can freely have them do system level stuff, such as thread management.