7 Replies Latest reply on Feb 29, 2008 8:22 AM by web websson

    Avoid service to start at startup

    web websson Newbie

      I am running a clustered instance of jboss 4.2.1 GA and deploying a service app.
      MyClusterService - which extends ServiceMBeanSupport - is triggered via the scheduler to run periodically.
      Here is the jboss-service.xml:

      <server>
       <mbean code="org.jboss.varia.scheduler.ScheduleManager"
       name="jboss:service=ScheduleManagerJSFDemo">
       <attribute name="StartAtStartup">false</attribute>
       </mbean>
      
       <mbean code="com.jsfdemo.mbean.MyClusterService"
       name="com.jsfdemo:service=MyClusterService">
       </mbean>
      
       <mbean code="org.jboss.varia.scheduler.SingleScheduleProvider"
       name="jboss:service=HAImportScheduleProviderJSFDemo">
      
       <depends>jboss:service=ScheduleManagerJSFDemo</depends>
       <depends>com.jsfdemo:service=ImportManager</depends>
      
       <attribute name="ScheduleManagerName">jboss:service=ScheduleManagerJSFDemo</attribute>
       <attribute name="TargetName">com.jsfdemo:service=MyClusterService</attribute>
       <attribute name="TargetMethod">perform( DATE, REPETITIONS )</attribute>
       <attribute name="DateFormat" />
       <attribute name="StartDate">NOW</attribute>
       <attribute name="Period">10000</attribute>
       <attribute name="Repetitions">-1</attribute>
       </mbean>
      </server>
      


      According documentation, if attribute "StartAtStartup" of ScheduleManager is set to false, the service should not trigger, which happends regardless the state of the element.
      Is this anyway to avoid the service to start at startup in this case?

      thank you.

        • 1. Re: Avoid service to start at startup
          web websson Newbie

          OK! I've create a very simple test project similar to ExampleHelloWorldService:

          The Management Interface:

          package com.demo;
          
          public interface HelloWorldServiceMBean extends ServiceMBean{
           public void perform(Date now, long remainingRepetitions);
          }
          


          The Service Implementation:
          package com.demo.mbean;
          
          public class HelloWorldService extends ServiceMBeanSupport implements HelloWorldServiceMBean{
          
           public void perform( Date now, long remainingRepetitions ){
           log.info( "[perform]: " + now.toString() );
           }
          }
          


          The deployment descriptor (jboss-service.xml):
          <server>
           <mbean code="org.jboss.varia.scheduler.ScheduleManager"
           name="jboss:service=ScheduleManagerDemo">
           <attribute name="StartAtStartup">false</attribute>
           </mbean>
          
           <mbean code="com.demo.mbean.HelloWorldService"
           name="com.demo:service=HelloWorldService">
           </mbean>
          
           <mbean code="org.jboss.varia.scheduler.SingleScheduleProvider"
           name="jboss:service=HAImportScheduleProviderDemo">
          
           <depends>jboss:service=ScheduleManagerDemo</depends>
           <depends>com.demo:service=HelloWorldService</depends>
          
           <attribute name="ScheduleManagerName">jboss:service=ScheduleManagerDemo</attribute>
           <attribute name="TargetName">com.demo:service=HelloWorldService</attribute>
           <attribute name="TargetMethod">perform( DATE, REPETITIONS )</attribute>
           <attribute name="DateFormat" />
           <attribute name="StartDate">NOW</attribute>
           <attribute name="Period">2000</attribute>
           <attribute name="Repetitions">-1</attribute>
           </mbean>
          </server>
          


          And everything deployed in a sar file with the following structure:

          hello-world.sar
          hello-world.sar/META-INF/jboss-service.xml
          hello-world.sar/com/demo/HelloWorldService.class
          hello-world.sar/com/demo/HelloWorldServiceMBean.class
          


          Despite the element StartAtStartup of ScheduleManager is set to false, the service trigger anyway.

          Is this a bug or did I missing?

          thanks.

          • 2. Re: Avoid service to start at startup
            Brian Stansberry Master

            This seems like a bug, at least in the docs. Looking at the code for the ScheduleManager class, the "StartAtStartup" property is not used at all. Actually, looking at the very first checkin of the class I don't see being used.

            • 3. Re: Avoid service to start at startup
              Brian Stansberry Master

              Let me look at this a bit more. TBH I haven't looked at this area in quite a while; I suspect there's another way to accomplish what you want.

              • 4. Re: Avoid service to start at startup
                Brian Stansberry Master

                OK, I was looking into using the Scheduler class instead of the ScheduleManager (see http://labs.jboss.com/file-access/default/members/jbossas/freezone/docs/Server_Configuration_Guide/beta422/html/Scheduling_Tasks-org.jboss.varia.scheduler.Scheduler_.html for example of Scheduler). But AFAICT it doesn't due anything with the StartAtStartup property either.

                Suggest you file a bug report in JIRA.

                • 6. Re: Avoid service to start at startup
                  Brian Stansberry Master

                  Thanks. :) I moved it to the JBAS project as it's really not a clustering issue. See JIRA comment for possible workaround.

                  • 7. Re: Avoid service to start at startup
                    web websson Newbie

                    Sorry for assignment ;)
                    OK, I've checked up your proposal workaround and made following changes:

                    own schedule manager:

                    public class ScheduleManagerExt extends ScheduleManager{
                    
                     private boolean started = false;
                    
                     @Override
                     public boolean isStarted(){
                     return started;
                     }
                    
                     @Override
                     public void startSchedules(){
                     this.started = true;
                     }
                    
                     @Override
                     public void stopSchedules(boolean pDoItNow){
                     this.started = false;
                     }
                    }


                    and deployment descriptor (jboss-service.xml):
                    <server>
                     <mbean code="com.demo.mbean..ScheduleManagerExt"
                     name="jboss:service=ScheduleManagerDemo">
                     <attribute name="StartAtStartup">false</attribute>
                     </mbean>
                    
                     ...
                    </server>
                    


                    but it doesn't fix the problem in any way.

                    Any other idea?

                    Thanks.