[jboss-user] [EJB3] - EJB 3.1 Timer problems in scheduling recurring task

Andrea Bennati do-not-reply at jboss.com
Wed Jan 5 09:46:58 EST 2011


Andrea Bennati [http://community.jboss.org/people/andrea-b] created the discussion

"EJB 3.1 Timer problems in scheduling recurring task"

To view the discussion, visit: http://community.jboss.org/message/579029#579029

--------------------------------------------------------------
I'm trying to use an EJB 3.1 Timer to schedule a recurring task every 5 minutes.
I'm using JBOSS 6.0.0.Final.

This is the simple code I have deployed:


import javax.ejb.Schedule;
import javax.ejb.Stateless;
import javax.ejb.Timeout;
 
/**
 * Session Bean implementation class AlerMonitorBean
 */
@Stateless
public class AlerMonitorBean {
 
    /**
     * Default constructor. 
     */
    public AlerMonitorBean() {
        // TODO Auto-generated constructor stub
    }
    
    @Schedule(minute="0/5")
    public void GestisciAlert() {
         System.out.println("Gestisti Alert - Tick"+System.currentTimeMillis());
    }
    
    @Timeout
    public void GestisciTimeout(){
         System.out.println("Timeout");

 }
}


import javax.ejb.Schedule;
import javax.ejb.Stateless;
import javax.ejb.Timeout;

/**
 * Session Bean implementation class AlerMonitorBean
 */
@Stateless
public class AlerMonitorBean {

    /**
     * Default constructor. 
     */
    public AlerMonitorBean() {
        // TODO Auto-generated constructor stub
    }

    @Schedule(minute="*/5")
    public void GestisciAlert() {
 System.out.println("Gestisti Alert - Tick -> "+System.currentTimeMillis());
        //TODO: insert code
    }    
}


I notice the following in Jboss Console:

15:40:00,006 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238400006
15:40:00,010 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238400010
15:40:01,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238401004
15:40:02,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238402004
15:40:03,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238403004
15:40:04,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238404004
15:40:05,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238405004
15:40:06,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238406004
15:40:07,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238407004
15:40:08,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238408003
15:40:09,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238409004
15:40:10,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238410003
15:40:11,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238411004
15:40:12,006 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238412006
15:40:13,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238413004
15:40:14,008 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238414008
15:40:15,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238415004
15:40:16,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238416004
15:40:17,008 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238417008
15:40:18,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238418004
15:40:19,003 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238419003
15:40:20,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238420004
15:40:21,003 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238421003
15:40:22,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238422004
15:40:23,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238423003
15:40:24,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238424004
15:40:25,003 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238425003
15:40:26,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238426004
15:40:27,003 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238427003
15:40:28,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238428004
15:40:29,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238429004
15:40:30,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238430004
15:40:31,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238431004
15:40:32,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238432004
15:40:33,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238433004
15:40:34,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238434004
15:40:35,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238435004
15:40:36,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238436004
15:40:37,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238437004
15:40:38,005 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238438005
15:40:39,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238439004
15:40:40,003 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238440003
15:40:41,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238441004
15:40:42,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238442004
15:40:43,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238443004
15:40:44,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238444004
15:40:45,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238445004
15:40:46,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238446004
15:40:47,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238447004
15:40:48,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238448004
15:40:49,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238449004
15:40:50,003 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238450003
15:40:51,003 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238451003
15:40:52,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238452004
15:40:53,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238453004
15:40:54,003 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238454003
15:40:55,008 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238455008
15:40:56,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238456004
15:40:57,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238457003
15:40:58,004 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238458004
15:40:59,003 INFO  [STDOUT] Gestisti Alert - Tick -> 1294238459003

I expected that method "GestisciAlert" was called once every 5 minutes.....

Every 5 minutes Timer starts and activates target method several times (about once per second) for a minute....
Then it stops and starts again after 4 minutes.

Hope someone can help me.

Andrea
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/579029#579029]

Start a new discussion in EJB3 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110105/1e78d786/attachment-0001.html 


More information about the jboss-user mailing list