--
You received this message because you are subscribed to the Google Groups "WildFly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wildfly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/a6ef08e9-270c-421b-8017-5f8629c0d731n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/f8e1a0dd-984e-43ef-9584-81adfa6ba7c1n%40googlegroups.com.
package org.jboss.as.quickstarts.ejb.timer;
import java.util.Collection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import jakarta.ejb.Singleton;
import jakarta.ejb.Startup;
import jakarta.ejb.Timeout;
import jakarta.ejb.Timer;
import jakarta.ejb.TimerConfig;
import jakarta.ejb.TimerService;
@Singleton
@Startup
public class TimeoutExample {
private static final Logger LOGGER = LoggerFactory.getLogger(TimeoutExample.class);
@Resource private TimerService timerService;
@Timeout
public void timeout(Timer timer) {
cancelTimers();
LOGGER.info("10 second timer executed");
}
@PostConstruct
public void initialize() {
cancelTimers();
timerService.createSingleActionTimer(10000, new TimerConfig());
LOGGER.info("10 second timer created");
}
private void cancelTimers() {
Collection<Timer> timers = timerService.getTimers();
for (Timer timer : timers) {
timer.cancel();
}
}
}
Build the war file and drop it into wildfly-31.0.1.Final/standalone/deployments
Then run:
standalone.sh --start-mode=suspend --server-config=standalone-full-ha.xml
Wait 20 seconds, then start the cli, connect, and run: :resume
You will see that the timer is lost
Interestingly under this configuration, the timer is not lost: standalone.sh --start-mode=suspend --server-config=standalone.xml
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/d9ac4430-9ba3-4b3d-b733-2b2a59adc57fn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/5baf679c-8ad5-4d08-8984-5edd12c29ddan%40googlegroups.com.