@PostConstruct public void initialize() { ScheduleExpression scheduleExpression = new ScheduleExpression() .hour("*") .minute("*") .second("*/5"); TimerConfig timerConfig = new TimerConfig(); timerConfig.setInfo("Every 5 second timer"); timerService.createCalendarTimer(scheduleExpression, timerConfig); }
@Stateless // or @Singleton public class MyTimerEJB { @Resource private TimerService timerService; @Timeout public void existingTimeoutMethod() { ... } public void fireTimeoutAsynchronouslyAlmostImmediately() { timerService.createSingleActionTimer(10, new TimerConfig(null, false)); } }
@PostConstruct public void init() { ts.createIntervalTimer(0l, TimeUnit.SECONDS.toMillis(1), new TimerConfig("a test timer", false)); }
private Timer createTimerInternal(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { TimerConfig tc = new TimerConfig(); tc.setInfo(info); return createTimerInternal(initialExpiration, intervalDuration, tc); }
private Timer createTimerInternal(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { TimerConfig tc = new TimerConfig(); tc.setInfo(info); return createTimerInternal(initialDuration, intervalDuration, tc); }
private Timer createTimerInternal(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { TimerConfig tc = new TimerConfig(); tc.setInfo(info); return createTimerInternal(initialDuration, intervalDuration, tc); }
private Timer createTimerInternal(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { TimerConfig tc = new TimerConfig(); tc.setInfo(info); return createTimerInternal(initialExpiration, intervalDuration, tc); }
public void start() { TimerConfig config = new TimerConfig(); config.setPersistent(false); timerService.createSingleActionTimer(100, config); }
public synchronized void reschedule(final String durationStr) { stop(); final long duration = new LongDuration(ofNullable(durationStr).orElse("1 minute")).getTime(MILLISECONDS); timer = timerService.createIntervalTimer(duration, duration, new TimerConfig(GracefulReleaser.class.getName() + ".run", false)); }
private synchronized void reschedule() { stop(); final long interval = policies.validationInterval("1 hour"); timer = service.createIntervalTimer(interval /*should it be something smaller?*/, interval, new TimerConfig(ExpirationNotifier.class.getName(), false)); }
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"); } }
/** * Schedule a job for regular execution. * <p/> * @param job * @param when The ScheduleExpression dictating when the job should be run. */ public void scheduleJobOnCalendar(Jobs job, ScheduleExpression when) { TimerConfig config = new TimerConfig(); config.setInfo(job.getId()); timerService.createCalendarTimer(when, config); }
/** * Schedule a job for a single execution, at the given date. * <p/> * @param job * @param when */ public void scheduleJobOnce(Jobs job, Date when) { TimerConfig config = new TimerConfig(); config.setInfo(job.getId()); timerService.createSingleActionTimer(when, config); }
@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)); } }
public Timer createCalendarTimer(ScheduleExpression schedule) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException, javax.ejb.EJBException { checkCreateTimerCallPermission(); checkScheduleExpression(schedule); TimerConfig tc = new TimerConfig(); tc.setInfo(null); return createTimerInternal(schedule, tc); }
public Timer createCalendarTimer(ScheduleExpression schedule) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException, javax.ejb.EJBException { checkCreateTimerCallPermission(); checkScheduleExpression(schedule); TimerConfig tc = new TimerConfig(); tc.setInfo(null); return createTimerInternal(schedule, tc); }
public void createCustomer(Customer04 customer) { em.persist(customer); ScheduleExpression birthDay = new ScheduleExpression().dayOfMonth(customer.getBirthDay()).month(customer.getBirthMonth()); timerService.createCalendarTimer(birthDay, new TimerConfig(customer, true)); }
public void register(final String clientId) { sendMessage(REGISTER_ENDPOINT, applicationConfig.toJSON()); ScheduleExpression schedule = new ScheduleExpression(); schedule.second("*/10").minute("*").hour("*").start(Calendar.getInstance().getTime()); TimerConfig config = new TimerConfig(); config.setPersistent(false); Timer timer = timerService.createCalendarTimer(schedule, config); LOGGER.config(() -> timer.getSchedule().toString()); }
public void register(final String clientId) { sendMessage(REGISTER_ENDPOINT, applicationConfig.toJSON()); ScheduleExpression schedule = new ScheduleExpression(); schedule.second("*/10").minute("*").hour("*").start(Calendar.getInstance().getTime()); TimerConfig config = new TimerConfig(); config.setPersistent(false); Timer timer = timerService.createCalendarTimer(schedule, config); LOGGER.config(() -> timer.getSchedule().toString()); }
@PostConstruct public void configure() { DeploymentStore store = new DeploymentStore(); store.setCommandService(commandService); setDeploymentStore(store); if (DEPLOY_SYNC_ENABLED) { ScheduleExpression schedule = new ScheduleExpression(); schedule.hour("*"); schedule.minute("*"); schedule.second("*/" + DEPLOY_SYNC_INTERVAL); timer = timerService.createCalendarTimer(schedule, new TimerConfig(null, false)); } }