3 Replies Latest reply on Jan 8, 2008 7:15 PM by manik

    Shutdown hooks

    manik

      This is in response to a user forum thread http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4089709#4089709 and it's corresponding JIRA JBCACHE-1204.

      What will happen for JBC 2.1.0.GA is that the default behaviour is:

      1. If an MBean server is detected, do not register a shutdown hook.
      2. Else, register a shutdown hook.

      To make things more sophisticated for cases where an MBean server may not control shutdown or a non-MBean server environment may control shutdown (such as a JBoss-MC standalone environment) there is a config parameter:

      
      <!--
       Available options:
       DEFAULT (this is selected if this config element is omitted)
       REGISTER (forces registering the hook, even if an MBean server is detected)
       DONT_REGISTER (does not register a hook, even if an MBean server is not detected)
      -->
      <attribute name="ShutdownHookBehaviour">DEFAULT</attribute>
      
      


      Any thoughts or comments on this? Brian?

        • 1. Re: Shutdown hooks
          manik

          Thinking about it a bit more, and particularly about the comment in the user forum thread to:

          1. remove any shutdown hooks in cache.stop() if this is called externally/manually
          2. add some intelligence in cache.stop() to detect if it is being called by the shutdown hook and don't remove the shutdown hook in this case

          With the above, do we then need any sort of manual override regarding the registration of shutdown hooks? Can we not then make do with *always* registering a shutdown hook, and then have the hook unregister if cache.stop() is called manually, or by an MBean server/microcontainer?

          Saves adding a configuration element.

          • 2. Re: Shutdown hooks
            brian.stansberry

            Re: always adding the hook, no that will break the AS. There is no way to specify ordering of shutdown hook execution. If JBC's own hook executes first, the proper undeployment ordering is not followed. For example, a clustered webapp should be undeployed before the cache is. A JBC hook executing first would break this, leading to all sorts of ugliness as the AS shutdown hook executes (this is what was happening before we put CR2 in AS 5.)

            Re: DEFAULT/REGISTER/DONT_REGISTER that sounds fine.

            • 3. Re: Shutdown hooks
              manik

              Ok, fair enough.