5 Replies Latest reply on Dec 13, 2004 3:25 AM by ssambi

    Another problem with Timer Service: duplication

    ssambi

      I've another problem with Timer Service, and I hope the last one.

      I've launched automatically my Timer Service when my application starts, that is in a Servlet Context Listener, as described in http://radio.weblogs.com/0135826/2004/09/21.html.

      I've noticed that my timer service is duplicated, so my bean's EjbTimeout method is invoked twice.
      I think this is due because of database persistence: my application launches the timer service, the server stores it in db and then the server recovers and launches timer services stored in db.

      I don't know if this is a bug or I did some inaccuracies; the latter is more probable, so I thank anyone can help me.

        • 1. Re: Another problem with Timer Service: duplication
          raist_majere

          There isn't a crash in my example, my problem occurs while Jboss is starting.

          Here are the steps I think Jboss works with my timers:
          - Jboss deploys my application
          - Jboss starts my application
          - The ServletContext of my application is initialized
          - My timers are created by my ServletContextListener
          - Jboss stores my timers in the database
          - Jboss starts my timers
          - Jboss restores and starts all timers found in the database (my timers too, although they didn't crashed, they are just created)
          - My timers are duplicated.

          Actually, if I deploy my application when Jboss has already started, the duplication doesn't occur.

          • 2. Re: Another problem with Timer Service: duplication
            raist_majere

            If you're using JBoss 4 (don't know if the same is in JBoss 3.2), you can configure the Timer Service editing the file ejb-deployer.xml file in the deploy dir. By default, as you guessed, is configured to persist the timers in the database, but in that file you can change this.

            • 3. Re: Another problem with Timer Service: duplication
              ssambi

              Thank you for your reply.
              I can change the ejb-deployer.xml file to avoid to store my timers in the database, but then I don't know if the timers can be restored after crashes and if they work in a cluster environment.

              • 4. Re: Another problem with Timer Service: duplication
                ssambi

                There isn't a crash in my example, my problem occurs while Jboss is starting.

                Here are the steps I think Jboss works with my timers:
                - Jboss deploys my application
                - Jboss starts my application
                - The ServletContext of my application is initialized
                - My timers are created by my ServletContextListener
                - Jboss stores my timers in the database
                - Jboss starts my timers
                - Jboss restores and starts all timers found in the database (my timers too, although they didn't crashed, they are just created)
                - My timers are duplicated.

                Actually, if I deploy my application when Jboss has already started, the duplication doesn't occur.