Java Code Examples for org.quartz.SchedulerException#printStackTrace()
The following examples show how to use
org.quartz.SchedulerException#printStackTrace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IndexStaticJob.java From Lottery with GNU General Public License v2.0 | 6 votes |
protected void executeInternal(JobExecutionContext context)throws JobExecutionException { try { SchedulerContext schCtx = context.getScheduler().getContext(); JobDataMap jdm=context.getJobDetail().getJobDataMap(); //获取Spring中的上下文 ApplicationContext appCtx = (ApplicationContext)schCtx.get("applicationContext"); this.cmsSiteMng= (CmsSiteMng)appCtx.getBean("cmsSiteMng"); this.staticPageSvc= (StaticPageSvc)appCtx.getBean("staticPageSvc"); this.sessionFactory=(SessionFactory) appCtx.getBean("sessionFactory"); this.siteId=Integer.parseInt((String) jdm.get(CmsTask.TASK_PARAM_SITE_ID)); } catch (SchedulerException e1) { // TODO 尚未处理异常 e1.printStackTrace(); } staticIndex(); }
Example 2
Source File: AppApplicationImpl.java From timer with Apache License 2.0 | 6 votes |
@Override public void unregister(String appName, String address) { AppPO appPO = appDomain.getAppInfo(appName, address); if (appPO != null) { appPO.setStatus(Boolean.FALSE); appDomain.updateAppStatus(appPO); List<String> addressList = appDomain.getAddressListByName(appName, Boolean.TRUE); if (CollectionUtils.isEmpty(addressList)) { try { quartzScheduler.pauseJobs(GroupMatcher.groupEquals(appName)); } catch (SchedulerException e) { e.printStackTrace(); } DefaultThreadPool.executor.submit(new ElephantTask(appName)); } } }
Example 3
Source File: JobServiceImpl.java From spring-boot-quartz-demo with MIT License | 6 votes |
/** * Stop a job */ @Override public boolean stopJob(String jobName) { System.out.println("JobServiceImpl.stopJob()"); try{ String jobKey = jobName; String groupKey = "SampleGroup"; Scheduler scheduler = schedulerFactoryBean.getScheduler(); JobKey jkey = new JobKey(jobKey, groupKey); return scheduler.interrupt(jkey); } catch (SchedulerException e) { System.out.println("SchedulerException while stopping job. error message :"+e.getMessage()); e.printStackTrace(); } return false; }
Example 4
Source File: JobResource.java From robe with GNU Lesser General Public License v3.0 | 6 votes |
/** * Return all HJobInfo as a collection * * @param credentials auto fill by {@link RobeAuth} annotation for authentication. * @return all {@link HJobInfo} as a collection */ @RobeService(group = "HJobInfo", description = "Returns all HJobInfo as a collection.") @GET @UnitOfWork(readOnly = true, cacheMode = GET, flushMode = FlushMode.MANUAL) public Collection<JobInfoDTO> getAll(@RobeAuth Credentials credentials, @SearchParam SearchModel search) { List<JobInfoDTO> dtoList = new LinkedList<>(); for (HJobInfo info : jobDao.findAllStrict(search)) { JobInfoDTO dto = new JobInfoDTO(info); try { if (!JobManager.getInstance().isScheduledJob(dto.getName(), dto.getGroup())) { dto.setStatus(JobInfoDTO.Status.UNSCHEDULED); } else { if (JobManager.getInstance().isPausedJob(dto.getName(), dto.getGroup())) { dto.setStatus(JobInfoDTO.Status.PAUSED); } else { dto.setStatus(JobInfoDTO.Status.ACTIVE); } } } catch (SchedulerException e) { e.printStackTrace(); } dtoList.add(dto); } return dtoList; }
Example 5
Source File: JobServiceImpl.java From spring-boot-quartz-demo with MIT License | 6 votes |
/** * Schedule a job by jobName at given date. */ @Override public boolean scheduleCronJob(String jobName, Class<? extends QuartzJobBean> jobClass, Date date, String cronExpression) { System.out.println("Request received to scheduleJob"); String jobKey = jobName; String groupKey = "SampleGroup"; String triggerKey = jobName; JobDetail jobDetail = JobUtil.createJob(jobClass, false, context, jobKey, groupKey); System.out.println("creating trigger for key :"+jobKey + " at date :"+date); Trigger cronTriggerBean = JobUtil.createCronTrigger(triggerKey, date, cronExpression, SimpleTrigger.MISFIRE_INSTRUCTION_FIRE_NOW); try { Scheduler scheduler = schedulerFactoryBean.getScheduler(); Date dt = scheduler.scheduleJob(jobDetail, cronTriggerBean); System.out.println("Job with key jobKey :"+jobKey+ " and group :"+groupKey+ " scheduled successfully for date :"+dt); return true; } catch (SchedulerException e) { System.out.println("SchedulerException while scheduling job with key :"+jobKey + " message :"+e.getMessage()); e.printStackTrace(); } return false; }
Example 6
Source File: JobSetter.java From NewsRecommendSystem with MIT License | 6 votes |
/** * 使用Quartz的表达式进行时间设定(默认为每天0点开始工作),详情请参照:http://www.quartz-scheduler.org/api/2.2.1/index.html(CronExpression) * 当启用该方法时,推荐系统可以保持运行,直到被强制关闭。 * @param userList */ private void executeQuartzJob(List<Long> userList) { //设定推荐任务每天的执行时间 String cronExpression=PropGetKit.getString("startAt"); try { if(enableCF) new CFCronTriggerRunner().task(userList,cronExpression); if(enableCB) new CBCronTriggerRunner().task(userList,cronExpression); if(enableHR) new HRCronTriggerRunner().task(userList,cronExpression); } catch (SchedulerException e) { e.printStackTrace(); } System.out.println("本次推荐结束于"+new Date()); }
Example 7
Source File: QuartzExecutor.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
public void incur(ITaskService taskService, ITaskDescriptor taskDescriptor) throws TaskException{ // test if the runnable can be instantiated taskService.instantiateRunnableById(taskDescriptor.getIdentifiedRunnableId()); String cron = taskDescriptor.getTriggerParameters().get("cron"); CronScheduleBuilder cronSchedule = CronScheduleBuilder.cronSchedule(cron); JobKey jobKey = new JobKey(taskDescriptor.getId()); JobDataMap jobDataMap = new JobDataMap(taskDescriptor.getRunContext()); jobDataMap.put("taskDescriptor", taskDescriptor); jobDataMap.put("taskService", taskService); JobDetail jobDetail = JobBuilder.newJob(TriggerTaskJob.class).withIdentity(jobKey).build(); Trigger trigger = TriggerBuilder.newTrigger().withIdentity(taskDescriptor.getId()) .withSchedule(cronSchedule).usingJobData(jobDataMap).build(); try { sched.scheduleJob(jobDetail, trigger); } catch (SchedulerException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
Example 8
Source File: StubSavedSearchController.java From DataHubSystem with GNU Affero General Public License v3.0 | 5 votes |
@RequestMapping(value = "/users/{userid}/searches", method = RequestMethod.GET) public List<Search> getUserSearches(final Principal principal, @PathVariable(value = "userid") final String userid, @RequestParam(value = "offset", defaultValue = "") final int offset, @RequestParam(value = "count", defaultValue = "") final int count) { List<Search> searches = null; final fr.gael.dhus.service.UserService userService = ApplicationContextProvider .getBean(fr.gael.dhus.service.UserService.class); final User u = (User) ((UsernamePasswordAuthenticationToken) principal).getPrincipal(); if (u == null) { throw new UserNotExistingException(); } logger.debug(" ***** parameters ***** "); logger.debug(" ***** offset ***** " + offset); logger.debug(" ***** count ***** " + count); searches = userService.scrollSearchesOfUser(u.getUUID(), offset, count); try { userService.getNextScheduleSearch(); } catch (final SchedulerException e) { logger.error("Error scheduling next search" + e.getMessage()); e.printStackTrace(); } return searches; }
Example 9
Source File: JobServiceImpl.java From spring-boot-quartz-demo with MIT License | 5 votes |
/** * Get the current state of job */ public String getJobState(String jobName) { System.out.println("JobServiceImpl.getJobState()"); try { String groupKey = "SampleGroup"; JobKey jobKey = new JobKey(jobName, groupKey); Scheduler scheduler = schedulerFactoryBean.getScheduler(); JobDetail jobDetail = scheduler.getJobDetail(jobKey); List<? extends Trigger> triggers = scheduler.getTriggersOfJob(jobDetail.getKey()); if(triggers != null && triggers.size() > 0){ for (Trigger trigger : triggers) { TriggerState triggerState = scheduler.getTriggerState(trigger.getKey()); if (TriggerState.PAUSED.equals(triggerState)) { return "PAUSED"; }else if (TriggerState.BLOCKED.equals(triggerState)) { return "BLOCKED"; }else if (TriggerState.COMPLETE.equals(triggerState)) { return "COMPLETE"; }else if (TriggerState.ERROR.equals(triggerState)) { return "ERROR"; }else if (TriggerState.NONE.equals(triggerState)) { return "NONE"; }else if (TriggerState.NORMAL.equals(triggerState)) { return "SCHEDULED"; } } } } catch (SchedulerException e) { System.out.println("SchedulerException while checking job with name and group exist:"+e.getMessage()); e.printStackTrace(); } return null; }
Example 10
Source File: ScheduledJobs.java From flowchat with GNU General Public License v3.0 | 5 votes |
public static void start() { // Another try { // Grab the Scheduler instance from the Factory Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler(); // and start it off scheduler.start(); JobDetail fetchFromReddit = newJob(RedditImporter.class) .build(); // Trigger the job to run now, and then repeat every x minutes Trigger fetchFromRedditTrigger = newTrigger() .startNow() .withSchedule(simpleSchedule() .withIntervalInHours(4) .repeatForever()) .build(); // Tell quartz to schedule the job using our trigger scheduler.scheduleJob(fetchFromReddit, fetchFromRedditTrigger); } catch (SchedulerException se) { se.printStackTrace(); } }
Example 11
Source File: JobResource.java From robe with GNU Lesser General Public License v3.0 | 5 votes |
/** * Returns all HTriggerInfo as a collection with the matches given job id. * * @param credentials auto fill by {@link RobeAuth} annotation for authentication. * @return all {@link HTriggerInfo} as a collection */ @RobeService(group = "HJobInfo", description = "Returns all HTriggerInfo as a collection with the matches given job id.") @PUT @Path("{id}/schedule") @UnitOfWork(readOnly = true, cacheMode = GET, flushMode = FlushMode.MANUAL) public boolean schedule(@RobeAuth Credentials credentials, @PathParam("id") String id) { HJobInfo info = jobDao.findById(id); if (info == null) { throw new WebApplicationException(Response.status(404).build()); } try { JobInfo dto = new HibernateJobInfoProvider().getJob(info.getJobClass()); JobDetail detail = HibernateJobInfoProvider.convert2JobDetail(dto); Set<Trigger> triggers = new HashSet<>(dto.getTriggers().size()); for (TriggerInfo triggerInfo : dto.getTriggers()) { if (triggerInfo.getType().equals(TriggerInfo.Type.CRON) || triggerInfo.getType().equals(TriggerInfo.Type.SIMPLE)) { triggers.add(HibernateJobInfoProvider.convert2Trigger(triggerInfo, dto)); } } JobManager.getInstance().scheduleJob(detail, triggers, false); return true; } catch (SchedulerException e) { e.printStackTrace(); return false; } }
Example 12
Source File: QuartzUtil.java From fixflow with Apache License 2.0 | 5 votes |
/** * 根据任务工厂拿到定时任务 * @param schedulerFactory 任务工厂 * @return */ public static Scheduler getScheduler(SchedulerFactory schedulerFactory) { Scheduler scheduler = null; try { scheduler = schedulerFactory.getScheduler(); } catch (SchedulerException e) { // TODO Auto-generated catch block e.printStackTrace(); } return scheduler; }
Example 13
Source File: JobServiceImpl.java From spring-boot-quartz-demo with MIT License | 5 votes |
/** * Pause a job */ @Override public boolean pauseJob(String jobName) { System.out.println("Request received for pausing job."); String jobKey = jobName; String groupKey = "SampleGroup"; JobKey jkey = new JobKey(jobKey, groupKey); System.out.println("Parameters received for pausing job : jobKey :"+jobKey+ ", groupKey :"+groupKey); try { schedulerFactoryBean.getScheduler().pauseJob(jkey); System.out.println("Job with jobKey :"+jobKey+ " paused succesfully."); return true; } catch (SchedulerException e) { System.out.println("SchedulerException while pausing job with key :"+jobName + " message :"+e.getMessage()); e.printStackTrace(); return false; } }
Example 14
Source File: QuartzUtil.java From fixflow with Apache License 2.0 | 5 votes |
/** * 根据定时任务和作业名称得到作业 * @param scheduler 定时任务 * @param jobKey 作业名称 * @return */ public static JobDetail getJobDetail(Scheduler scheduler, String jobKey) { JobDetail jobDetail = null; try { jobDetail = scheduler.getJobDetail(new JobKey(jobKey)); } catch (SchedulerException e) { // TODO Auto-generated catch block e.printStackTrace(); } return jobDetail; }
Example 15
Source File: JobScheduler.java From elasticsearch-mysql with MIT License | 5 votes |
private JobScheduler() { SchedulerFactory sf = new StdSchedulerFactory(); try { scheduler = sf.getScheduler(); scheduler.getListenerManager().addJobListener(new Listener(), allJobs()); } catch (SchedulerException e) { e.printStackTrace(); } }
Example 16
Source File: TaskServiceImpl.java From yyblog with MIT License | 5 votes |
@Override public int removeBatch(Long[] ids) { for (Long id : ids) { try { TaskDO task = get(id); quartzManager.deleteJob(task); } catch (SchedulerException e) { e.printStackTrace(); return 0; } } return taskMapper.removeBatch(ids); }
Example 17
Source File: TaskServiceImpl.java From yyblog with MIT License | 5 votes |
@Override public int remove(Long id) { try { TaskDO task = get(id); quartzManager.deleteJob(task); return taskMapper.remove(id); } catch (SchedulerException e) { e.printStackTrace(); return 0; } }
Example 18
Source File: JobScheduler.java From elasticsearch-mysql with MIT License | 5 votes |
public boolean isRunning(String jobKey) { try { for (JobExecutionContext context : scheduler.getCurrentlyExecutingJobs()) { // logger.info(context.getJobDetail().getKey().getName() + " is running"); if (context.getJobDetail().getKey().getName().equals(jobKey)) { return true; } } } catch (SchedulerException e) { logger.info("get jobs status failed"); e.printStackTrace(); } return false; }
Example 19
Source File: TriggerServiceStrategy.java From quartz-web with Apache License 2.0 | 5 votes |
public static JSONResult runTrigge(String schedulerName, String triggerName, String triggerGroup) { try { QuartzWebManager.runTrigger(schedulerName, triggerName, triggerGroup); return JSONResult.build(JSONResult.RESULT_CODE_SUCCESS, "ok"); } catch (SchedulerException e) { e.printStackTrace(); return JSONResult.build(JSONResult.RESULT_CODE_ERROR, e.getMessage()); } }
Example 20
Source File: AppApplicationImpl.java From timer with Apache License 2.0 | 5 votes |
@Override public void register(String appName, String address) { //LOGGER.info("Application registering:appName[{}], address[{}]", appName, address); List<String> addressList = appDomain.getAddressListByName(appName, Boolean.TRUE); AppPO appPO = appDomain.getAppInfo(appName, address); if (appPO == null) { appPO = new AppPO(appName, address, Boolean.TRUE); appDomain.addNewApp(appPO); } else if (!appPO.getStatus()) { changeAppStatus(appPO.getId(), Boolean.TRUE); } else { appDomain.updateActiveTime(appName, address); } //LOGGER.info("Application registered"); if (CollectionUtils.isEmpty(addressList)) { List<JobPO> jobPOS = jobDomain.getJobListByAppName(appName); try { if (CollectionUtils.isNotEmpty(jobPOS)) { for (JobPO jobPO : jobPOS) { quartzScheduler.resumeJob(JobKey.jobKey(jobPO.getJobName(), appName)); } } } catch (SchedulerException e) { e.printStackTrace(); } } }