7 Replies Latest reply on Dec 16, 2007 4:51 PM by Pete Muir

    Asynchronous method triggered multiple times.

    Vincent Faidherbe Newbie

      I've a Stateless local Session Bean which defines an asynchronous method which is launched at startup by an observer method.

      Everything works fine except that the method is triggered multiple times simultaneously. Any idea why?

      Neither the TimeService implementation nor the Quartz implementation solves the issue.

      Here's the Session Bean interface:

      public interface SendMailJob {
       public void processMailQueue(@Duration long start, @IntervalDuration long interval);

      Here's the Session Bean implementation:

      @Stateless(name = "SendMailJob")
      public class SendMailJobImpl implements SendMailJob {
       private DataSource dataSource;
       private Session mailSession;
       private Log log;
       public void processMailQueue(long start, long interval) {
       // ...

      Here's the component that launches the asynchronous method at startup:

      public class SendMailJobLauncher {
       private long interval;
       public void setInterval(long interval) {
       this.interval = interval * 60 * 60 * 1000;
       // ========
       // Resource
       // ========
       @In(create = true)
       private SendMailJob sendMailJob;
       private Log log;
       public void statup() {
       log.info("startup() launch sendMailJob [interval: {0}]", interval);
       sendMailJob.processMailQueue(2 * 60 * 1000, interval);