1 2 Previous Next 24 Replies Latest reply on May 30, 2007 1:22 AM by Pranjal Mathur

    Scheduler Jboss

    Antonio Dias Newbie

      Hello, I have a problem with the scheduler. I saw some examples but nothing to much clear. I have a stateless session bean. And i want to call one business method of this session bean every five minutes. How could i do that?

      Thanks in advance.

        • 1. Re: Scheduler Jboss
          Armenio Pinto Newbie

           

          "acardeiradias" wrote:
          Hello, I have a problem with the scheduler. I saw some examples but nothing to much clear. I have a stateless session bean. And i want to call one business method of this session bean every five minutes. How could i do that?

          Thanks in advance.


          http://www.huihoo.com/jboss/online_manual/3.0/ch13s58.html

          - implement the Schedulable interface;
          - create jboss-service.xml;
          - deploy.

          Arménio Pinto

          • 2. Re: Scheduler Jboss
            Antonio Dias Newbie

             

            "apinto" wrote:
            "acardeiradias" wrote:
            Hello, I have a problem with the scheduler. I saw some examples but nothing to much clear. I have a stateless session bean. And i want to call one business method of this session bean every five minutes. How could i do that?

            Thanks in advance.


            http://www.huihoo.com/jboss/online_manual/3.0/ch13s58.html

            - implement the Schedulable interface;
            - create jboss-service.xml;
            - deploy.

            Arménio Pinto


            I saw that link before write this post. The problem is that this Link don't work.

            • 3. Re: Scheduler Jboss
              Antonio Dias Newbie

              I solve my problem. I find how to do that. I leave here my solution, because this could help other people.

              1- Create a session bean that implements Schedulable.
              2- Implements the method "perform" and put there the code to be executed by Scheduler
              3- create a jboss-service.xml and put this file in a sar file. One extract of Jboss-service.xml:

              <!--
               | This example shows how to use a pluggable Schedulable impl
               -->
               <mbean code="org.jboss.varia.scheduler.Scheduler" name=":service=JbossClientCentralServerSendMessagesScheduler">
               <attribute name="StartAtStartup">true</attribute>
               <attribute name="SchedulableClass">pt.link.clientCentralServer.businessLogic.session.CaptureInformationClientFacadeSession</attribute>
               <attribute name="InitialStartDate">NOW</attribute>
               <attribute name="SchedulePeriod">2000</attribute>
              <!-- <attribute name="SchedulePeriod">2000</attribute>-->
               <attribute name="InitialRepetitions">-1</attribute>
               </mbean>




              • 4. Re: Scheduler Jboss
                Michael Caughey Newbie

                For the record it doesn't have to be a Session bean that implements a Schedulable. It can be a POJO.

                • 5. Re: Scheduler Jboss
                  Dan Johnsson Newbie

                  I am confused by the SchedulePeriod attribute. It seems like its semantics have changed.

                  I thought it meant "time between starts" (3.2.5). However, in 3.2.7 it seems to mean "time from finish until next start".

                  Does anybody know which is intended?

                  Dan

                  <!--
                   | This example shows how to use a pluggable Schedulable impl
                   -->
                   <mbean code="org.jboss.varia.scheduler.Scheduler" name=":service=JbossClientCentralServerSendMessagesScheduler">
                   <attribute name="StartAtStartup">true</attribute>
                   <attribute name="SchedulableClass">pt.link.clientCentralServer.businessLogic.session.CaptureInformationClientFacadeSession</attribute>
                   <attribute name="InitialStartDate">NOW</attribute>
                   <attribute name="SchedulePeriod">2000</attribute>
                  <!-- <attribute name="SchedulePeriod">2000</attribute>-->
                   <attribute name="InitialRepetitions">-1</attribute>
                   </mbean>




                  • 6. Re: Scheduler Jboss
                    Ulf Schroeter Novice

                    Up to my knowledge it has always been "time from finish until next start".

                    Regards
                    Ulf

                    • 7. Re: Scheduler Jboss
                      Dan Johnsson Newbie

                       

                      "schrouf" wrote:
                      Up to my knowledge it has always been "time from finish until next start".


                      Strange. We have a nightly job that takes somewhere between 8 s and 50 min. We have configured it with SchedulePeriod = 24 * 60 * 60 * 1000.

                      Using 3.2.5, the job has started same time every night (01:00), and finishin within the hour, in good time before people arrive in the morning.

                      However, since upgrading to 3.2.7, the jobs have start "slipping", i e starting later and later. And, the slip is exactly the time the job took, i e starting at the last nights finish-time. If this is the intended behaviour, it feels strange.

                      • 8. Re: Scheduler Jboss
                        Ulf Schroeter Novice

                        If this is the intended behaviour, it feels strange

                        Well, at least it is the implemented behaviour :-) But I do share your feelings that a rescheduling relativ to the start (and not the end) of the previous invocation most often would be a better solution. A special case would be when the processing time always is larger than the rescheduling time as this would cause a continous execution. So the best solution would be to make the actual behaviour configurable (e.g 'SchedulePeriodCompensation'=true/false). If you need such a feature then you should open a JIRA feature request. Maybe I will find the time for a CVS update.

                        Regards
                        Ulf

                        • 9. Re: Scheduler Jboss
                          Ken Cheng Newbie

                          When I tried using a POJO which implements the Schedulable interface and calls a Session bean's method in it's perform method, it always returns NamingException, although I have already put "depends" tag in the "scheduler-service.xml" file to make sure the session bean's service "jboss.j2ee:service=EJB" and "jboss.j2ee:service=EjbModule" are deployed already before starting the scheduler. Is there any "depends" settings that I have missed?

                          I am using xDoclet generated Util class of the session bean to locate the Home interface so typo in the JNDI reference is not possible. The session bean has both remote and local interfaces that I have also tried but in vain. Any hints and help will be very much appreciated.

                          • 10. Re: Scheduler Jboss
                            Fabrizio Variano Newbie

                            Hello. I have the problem with the scheduler.
                            I follow these phases:
                            1- Create a session bean that implements Schedulable.
                            2- Implements the method "perform" and put there the code to be executed by Scheduler
                            3- create a jboss-service.xml and put this file in a sar file.

                            Then during of deploy return me this error:

                            ERROR [Scheduler$Listener] Handling a Scheduler call failed
                            java.lang.NullPointerException
                            at org.jboss.mx.loading.UnifiedClassLoader.findResources(UnifiedClassLoader.java:395)
                            at java.lang.ClassLoader.getResources(ClassLoader.java:851)
                            at com.sun.naming.internal.VersionHelper12$5.run(VersionHelper12.java:145)
                            at java.security.AccessController.doPrivileged(Native Method)
                            at com.sun.naming.internal.VersionHelper12.getResources(VersionHelper12.java:142)
                            at com.sun.naming.internal.ResourceManager.getApplicationResources(ResourceManager.java:468)
                            at com.sun.naming.internal.ResourceManager.getInitialEnvironment(ResourceManager.java:159)
                            at javax.naming.InitialContext.init(InitialContext.java:215)
                            at javax.naming.InitialContext.(InitialContext.java:175)
                            at sistemiMW.ejb.RestartTimerBean.perform(RestartTimerBean.java:114)
                            at org.jboss.varia.scheduler.Scheduler$Listener.handleNotification(Scheduler.java:1263)
                            at sun.reflect.GeneratedMethodAccessor41.invoke(Unknown Source)
                            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                            at java.lang.reflect.Method.invoke(Method.java:324)
                            at org.jboss.mx.notification.NotificationListenerProxy.invoke(NotificationListenerProxy.java:138)
                            at $Proxy8.handleNotification(Unknown Source)
                            at javax.management.NotificationBroadcasterSupport.handleNotification(NotificationBroadcasterSupport.java:98)
                            at javax.management.NotificationBroadcasterSupport.sendNotification(NotificationBroadcasterSupport.java:83)
                            at javax.management.timer.Timer.sendNotifications(Timer.java:441)
                            at javax.management.timer.Timer.access$000(Timer.java:31)
                            at javax.management.timer.Timer$RegisteredNotification.doRun(Timer.java:612)
                            at org.jboss.mx.util.SchedulableRunnable.run(SchedulableRunnable.java:164)
                            at org.jboss.mx.util.ThreadPool$Worker.run(ThreadPool.java:240)


                            In method perform i call a business method of an entity bean.

                            Any ideas to solving this problem?

                            Thank you.


                            • 11. Re: Scheduler Jboss
                              Dimitris Andreadis Master

                              Scheduleables in this context have nothing to do with EJBs. They are simple POJOs or MBeans.

                              • 12. Re: Scheduler Jboss
                                Fabrizio Variano Newbie

                                Hi dimitris.
                                Therefore which is my problem? I don't understand what you tell me. How can i solve this problem?

                                Thanks

                                • 13. Re: Scheduler Jboss
                                  Abrhaão Ribeiro Newbie

                                  I have a problem with the attribute InitialStartDate.
                                  It cannot be NOW in this specifically case.

                                  I would like to know how can I configure my scheduler-service to execute the SchedulableMBean:

                                  - everyday, 02 a.m

                                  - every JBoss startup, 5 minutes after the startup

                                  thanks

                                  • 14. Re: Scheduler Jboss
                                    Anders Norrbom Newbie

                                     

                                    "ctken" wrote:
                                    When I tried using a POJO which implements the Schedulable interface and calls a Session bean's method in it's perform method, it always returns NamingException, although I have already put "depends" tag in the "scheduler-service.xml" file to make sure the session bean's service "jboss.j2ee:service=EJB" and "jboss.j2ee:service=EjbModule" are deployed already before starting the scheduler. Is there any "depends" settings that I have missed?

                                    I am using xDoclet generated Util class of the session bean to locate the Home interface so typo in the JNDI reference is not possible. The session bean has both remote and local interfaces that I have also tried but in vain. Any hints and help will be very much appreciated.



                                    I am experiencing a similar problem, I have a stateless session bean implementing the Schedulable interface and it seems like I cant use any other dependency injected beans from the perform() method.
                                    Do I have to make a JNDI lookup?

                                    1 2 Previous Next