use of javax.ejb.TimerConfig in project jbpm by kiegroup.
the class DeploymentSynchronizerCDInvoker method configure.
@PostConstruct
public void configure() {
if (DeploymentSynchronizer.DEPLOY_SYNC_ENABLED) {
ScheduleExpression schedule = new ScheduleExpression();
schedule.hour("*");
schedule.minute("*");
schedule.second("*/" + DeploymentSynchronizer.DEPLOY_SYNC_INTERVAL);
timer = timerService.createCalendarTimer(schedule, new TimerConfig(null, false));
}
}
use of javax.ejb.TimerConfig in project jbpm by kiegroup.
the class EJBTimerScheduler method internalSchedule.
public void internalSchedule(TimerJobInstance timerJobInstance) {
TimerConfig config = new TimerConfig(new EjbTimerJob(timerJobInstance), true);
Date expirationTime = timerJobInstance.getTrigger().hasNextFireTime();
logger.debug("Timer expiration date is {}", expirationTime);
if (expirationTime != null) {
timerService.createSingleActionTimer(expirationTime, config);
logger.debug("Timer scheduled {} on {} scheduler service", timerJobInstance);
localCache.putIfAbsent(((EjbGlobalJobHandle) timerJobInstance.getJobHandle()).getUuid(), timerJobInstance);
} else {
logger.info("Timer that was to be scheduled has already expired");
}
}
use of javax.ejb.TimerConfig in project wildfly by wildfly.
the class TimerServiceSuspendTestCase method testIntervalTimersDoNotBackUp.
/**
* This test makes sure that interval timers that are scheduled while a timer is suspended do not back up, and only a single
* run will occur when the container is resumed
*/
@Test
public void testIntervalTimersDoNotBackUp() throws NamingException, IOException, InterruptedException {
SuspendTimerServiceBean.resetTimerServiceCalled();
InitialContext ctx = new InitialContext();
SuspendTimerServiceBean bean = (SuspendTimerServiceBean) ctx.lookup("java:module/" + SuspendTimerServiceBean.class.getSimpleName());
Timer timer = null;
try {
long start = 0;
ModelNode op = new ModelNode();
try {
op.get(ModelDescriptionConstants.OP).set("suspend");
managementClient.getControllerClient().execute(op);
// create the timer while the container is suspended
start = System.currentTimeMillis();
timer = bean.getTimerService().createIntervalTimer(100, 100, new TimerConfig("", false));
Thread.sleep(5000);
Assert.assertEquals(0, SuspendTimerServiceBean.getTimerServiceCount());
} finally {
op = new ModelNode();
op.get(ModelDescriptionConstants.OP).set("resume");
managementClient.getControllerClient().execute(op);
}
// if they were backed up we give them some time to run
Thread.sleep(300);
int timerServiceCount = SuspendTimerServiceBean.getTimerServiceCount();
Assert.assertTrue("Interval " + (System.currentTimeMillis() - start) + " count " + timerServiceCount, timerServiceCount < 40);
} finally {
if (timer != null) {
timer.cancel();
Thread.sleep(100);
}
}
}
use of javax.ejb.TimerConfig in project wildfly by wildfly.
the class TimerServiceSuspendTestCase method testSuspendWithIntervalTimer.
@Test
public void testSuspendWithIntervalTimer() throws NamingException, IOException, InterruptedException {
SuspendTimerServiceBean.resetTimerServiceCalled();
InitialContext ctx = new InitialContext();
SuspendTimerServiceBean bean = (SuspendTimerServiceBean) ctx.lookup("java:module/" + SuspendTimerServiceBean.class.getSimpleName());
ModelNode op = new ModelNode();
Timer timer = null;
try {
try {
timer = bean.getTimerService().createIntervalTimer(100, 100, new TimerConfig("", false));
Assert.assertTrue(SuspendTimerServiceBean.awaitTimerServiceCount() > 0);
op.get(ModelDescriptionConstants.OP).set("suspend");
managementClient.getControllerClient().execute(op);
SuspendTimerServiceBean.resetTimerServiceCalled();
Thread.sleep(200);
Assert.assertEquals(0, SuspendTimerServiceBean.getTimerServiceCount());
} finally {
op = new ModelNode();
op.get(ModelDescriptionConstants.OP).set("resume");
managementClient.getControllerClient().execute(op);
}
Assert.assertTrue(SuspendTimerServiceBean.awaitTimerServiceCount() > 0);
} finally {
if (timer != null) {
timer.cancel();
Thread.sleep(100);
}
}
}
use of javax.ejb.TimerConfig in project wildfly by wildfly.
the class NonPersistentTimerServiceBean method createTimer.
public void createTimer() {
TimerConfig timerConfig = new TimerConfig();
timerConfig.setPersistent(false);
timerService.createIntervalTimer(100, 100, timerConfig);
}
Aggregations