2 Replies Latest reply on Nov 4, 2004 10:17 AM by Victor Batista

    Clean Shutdown of MBean

    Victor Batista Newbie

      I have developed an MBean which executes every N minutes, launched by the JBoss Scheduler service (It runs in a clustered environment as a Singleton).
      I must guarantee that when JBoss Shutdown is invoked, and if my MBean is executing, JBoss waits until the current execution finishes. It's something like a Shutdown Hook, or like the CleanShutdownInterceptor which can be used for EJBs.
      How can I have this behavior with my MBean?

      Many thanks in advance,
      Victor Batista

        • 1. Re: Clean Shutdown of MBean
          Dimitris Andreadis Master

          Haven't used the Scheduler but looking at the code quickly it seems the execution thread is that of the jmx Timer, and it's not very obvious if it does a clean shutdown (it creates daemon thread by default, though).

          So, do you get a clean shutdown?

          If not, you can try to synchronize your serviceStop() with e.g. a Boolean shutdown flag inside your MBean. You doSomething() will also synchronise on that and make sure also it is not set (in case a call comes after serviceStop() has been called).

          • 2. Re: Clean Shutdown of MBean
            Victor Batista Newbie

            Thanks Dimitris!
            I have it working according to your suggestion!! I had to override the stopService() method with a synchronized boolean variable.

            Victor Batista