Tag: quartz scheduler

如何从Quartz调度程序查询预定作业?

我的应用程序中有一个Scheduler对象,我使用scheduleJob方法将Job添加到它。 在我的代码中,我使用即时Trigger安排Job s: TriggerBuilder.newTrigger().startNow().build(); 我的问题是如何判断哪些Job被安排到我的Scheduler ? 到目前为止,只有一个getCurrentlyExecutingJobs方法似乎不可靠。

Quartz Scheduler:如何通过API从Java动态读取quartz属性?

Quartz通常通过类路径上的quartz.properties进行配置。 例如: org.quartz.scheduler.instanceName = BagginsScheduler org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool org.quartz.threadPool.threadCount=5 org.quartz.threadPool.threadPriority=1 从运行Quartz作业的同一个应用程序中, 我想读出属性。 读取调度程序名称很简单: Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler(); String name = scheduler.getSchedulerName(); 但是我如何阅读`threadPriority’属性? 以下不起作用: scheduler.getContext().getString(“org.quartz.threadPool.threadPriority”); 更新的解决方案 :似乎无法通过Quartz API读取属性,您必须通过常规Properties : Properties prop = new Properties(); prop.load(AnyClassUsedByJVM.class.getClassLoader().getResourceAsStream(“quartz.properties”)); String prio = prop.getProperty(“org.quartz.threadPool.threadPriority”); 这很好用。

Quartz调度程序 – 之间的时间

我正在使用石英调度程序来安排工作。我有一个案例,我希望每天晚上(晚上9点)到第二天早上(06:00 AM)执行工作。我怎样才能实现这一点。目前我正在初始化像这样触发 Trigger trigger2 = newTrigger() .withIdentity(“trigger1”, “group1”) .startNow() .withSchedule(simpleSchedule() .withIntervalInSeconds(10) .repeatForever()) .build(); 我需要做些什么修改才能满足要求?

泽西岛2.0:创造重复的工作

在我们的REST服务中,我们希望实现一个每10秒检查一次的工作。 所以我们认为我们可以使用Quartz制作一个涵盖这个的Job。 但问题是,我们需要注入一个单例,因为它在作业中使用,并且作业似乎不在我们的服务上下文中,因此注入的类始终为null(NullPointerException)。 那么有没有另一种可能的解决方案来实现这样的工作而不使用Quartz? 我们已经尝试编写自己的JobFactory来连接作业和BeanManager,但它根本没用。 这是无法正常工作的代码: @Stateless public class GCEStatusJob implements Job, Serializable{ private Logger log = LoggerFactory.getLogger(GCEStatusJob.class); @Inject SharedMemory sharedMemory; @Override public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { GoogleComputeEngineFactory googleComputeEngineFactory = new GoogleComputeEngineFactory(); List heartbeatList = new ArrayList(sharedMemory.getAllHeartbeats()); List gceList = googleComputeEngineFactory.listGCEs(); List ipAddressList = gceList.stream().map(GCE::getIp).collect(Collectors.toList()); for(HeartbeatModel heartbeat : heartbeatList){ if(ipAddressList.contains(heartbeat.getIpAddress())){ long systemTime = […]

如何在JBoss6中动态添加Quartz作业

我正在使用JBoss6并希望动态创建Quartz-Jobs。 在处理作业期间,将定义下一个开始时间(例如,在1,5或10小时内)。 我没有找到任何解决方案,甚至很难访问org.quartz.Scheduler (参见JBoss AS 6中的QuartzScheduler注入 )。 下一个问题是创建新的工作,我按照教程http://www.quartz-scheduler.org/docs/tutorial/TutorialLesson02.html : import static org.quartz.JobBuilder.*; import static org.quartz.SimpleScheduleBuilder.*; import static org.quartz.CronScheduleBuilder.*; import static org.quartz.CalendarIntervalScheduleBuilder.*; import static org.quartz.TriggerBuilder.*; import static org.quartz.DateBuilder.*; // define the job and tie it to our HelloJob class JobDetail job = newJob(HelloJob.class) .withIdentity(“myJob”, “group1”) // name “myJob”, group “group1” .build(); // Trigger the job to […]

改变石英作业计划

我正在考虑使用Quartz安排我的应用程序,但在所有情况下,作业触发器似乎是一次性活动,并且对触发器的更改需要重新部署应用程序才能生效。 是否有任何方法可以让作业触发器检查作业计划的更改而无需重新部署代码? 谢谢,

Quartz属性不会触发Quartz Job

我正在使用Quartz 2.1.3。 我的quartz.properties : #=================================================== # Configure the Job Initialization Plugin #=================================================== org.quartz.plugin.jobInitializer.class = org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin org.quartz.plugin.jobInitializer.fileNames = quartz-jobs.xml org.quartz.plugin.jobInitializer.failOnFileNotFound = true org.quartz.plugin.jobInitializer.scanInterval = 10 org.quartz.plugin.jobInitializer.wrapInUserTransaction = false 我的quart-jobs.xml : myjob MYJOBGROUP Job to Test com.upd.test.TestQuartz my-trigger MYTRIGGER_GROUP myjob MYJOBGROUP 0/5 * * * * ? 我的web.xml : quartz:config-file quartz.properties quartz:shutdown-on-unload true quartz:wait-on-shutdown false quartz:start-scheduler-on-load true […]

如何以动态方式创建Spring Beans。 使用Quartz SchedulerFactoryBean

我有一个QuartzJobConfig类,我注册了我的Spring-Quartz-Beans 。 我遵循了SchedulerFactoryBean , JobDetailFactoryBean和CronTriggerFactoryBean的指令。 我的作业在应用程序外部的yaml文件中配置。 意味着我必须在应用程序启动时动态创建Bean。 我的配置: channelPartnerConfiguration: channelPartners: – code: Job1 jobConfigs: – schedule: 0 * * ? * MON-FRI name: Job1 daily hotel: false allotment: true enabled: true – schedule: 30 * * ? * MON-FRI name: Job2 weekly hotel: true allotment: false enabled: true … 我的配置类: @Configuration public class QuartzJobConfig implements […]

使用Quartz获取数据库连接

我有一个要求,我需要在我的调度过程中插入数据并检索相同的内容。尽管我可以创建自己的连接类并且可以完成工作,但我想知道是否有办法使用Quartz API获取数据库连接。 由于Quartz有效地进行数据库连接和处理,所以我的目的是使用一个定义良好的结构而不是创建自己的结构。 我在Quartz中看到了以下代码 conn = DBConnectionManager.getInstance().getConnection( getDataSource()); 但我不确定这种方法有多好,以获得连接。或者有任何好的示例/资源来创建一个有效的数据库连接类。 Quartz属性文件 org.quartz.scheduler.instanceName=QuartzScheduler org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX org.quartz.threadPool.threadCount=7 org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.MSSQLDelegate org.quartz.jobStore.tablePrefix = QRTZ_ org.quartz.jobStore.dataSource = myDS org.quartz.dataSource.myDS.driver=com.mysql.jdbc.Driver org.quartz.dataSource.myDS.URL=jdbc:mysql://localhost:3306/quartz org.quartz.dataSource.myDS.user=root org.quartz.dataSource.myDS.password=root org.quartz.dataSource.myDS.maxConnections=5

Quartz调度程序不显示Log4j消息

我正在尝试配置我的Quartz调度程序以支持日志记录。 我曾尝试做以下事情: 在我的应用程序的classes文件夹中添加了log4j.xml。 相同的代码是: log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern= %d{ABSOLUTE} %5p %c{1}:%L – %m%n log4j.rootLogger=debug, stdout 在我的调度程序类中添加了以下语句: static Logger logger = Logger.getLogger(“QuartzReport.class”); logger.info(“Info”); 但是,控制台在启动时显示以下消息: log4j:WARN No appenders could be found for logger (org.quartz.simpl.SimpleThreadPool). log4j:WARN Please initialize the log4j system properly. 请告诉我,我是否遗漏了某些东西。 此致,伊布