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:
| @Local
| public interface SendMailJob {
|
| @Asynchronous
| public void processMailQueue(@Duration long start, @IntervalDuration
long interval);
|
| }
|
Here's the Session Bean implementation:
| @Stateless(name = "SendMailJob")
| @Name("sendMailJob")
| public class SendMailJobImpl implements SendMailJob {
|
| @Resource(name="jdbc/luxair_asr_Datasource")
| private DataSource dataSource;
|
| @Resource(name="mail/luxair_asr_MailSession")
| private Session mailSession;
|
|
| @Logger
| private Log log;
|
|
| public void processMailQueue(long start, long interval) {
|
| // ...
| }
| }
|
Here's the component that launches the asynchronous method at startup:
| @Name("sendMailJobLauncher")
| public class SendMailJobLauncher {
| private long interval;
|
| public void setInterval(long interval) {
| this.interval = interval * 60 * 60 * 1000;
| }
|
| // ========
| // Resource
| // ========
|
| @In(create = true)
| private SendMailJob sendMailJob;
|
| @Logger
| private Log log;
|
| @Observer("org.jboss.seam.postInitialization")
| public void statup() {
| log.info("startup() launch sendMailJob [interval: {0}]", interval);
| sendMailJob.processMailQueue(2 * 60 * 1000, interval);
| }
| }
|
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4110520#4110520
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4110520
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user