1 Reply Latest reply on Mar 17, 2004 5:05 AM by mrtom

    How do I schedule a task for action

    offline

      Alright, I know that this is not a new question, but most of what i've seen doesn't seem to apply to what i'm trying to accomplish, so please bear with me.

      What i'd like to do is have a task of some kind running on the server that, every night at midnight, for example, will send an e-mail message depending on the results of some DB queries.

      I'm thinking of putting it in a servlet and figuring out how to load the servlet on startup and then force JBoss to keep the servlet active, but that seems to me to be a bit of a brute-force inelegant solution. Can someone suggest a way that might be a bit cleaner, more portable, etc? I know next to nothing about J2EE programming in general, so i might even be asking the wrong question entirely. Is this an EJB-type problem, for example?

      Thanks in advance.

        • 1. Re: How do I schedule a task for action
          mrtom

          If you look in your server/default/deploy/scheduler-service.xml you'll see the two ways in which you can set up a scheduled task.

          The quickest way is to implement the first method. In the declaration you'll notice that it references org.jboss.varia.scheduler.example.SchedulableExample - if you look at the source code for that class you'll see how to do yours.

          This method will lock you in to JBoss so if you really need portability then this may not help you. The second method will make your code more portable but requires writing your own MBean - this is how I prefer to do them. (I think portability is the only difference between the two)