如何在JBoss6中动态添加Quartz作业 [英] How to dynamically add a Quartz Job in JBoss6

查看:135
本文介绍了如何在JBoss6中动态添加Quartz作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JBoss6并希望动态创建Quartz-Jobs。在处理作业期间,将定义下一个开始时间(例如,在1,5或10小时内)。

I'm using JBoss6 and want to dynamically create Quartz-Jobs. During the processing of the job the next start time will be defined (e.g. in 1, 5 or 10 hours).

我没有找到任何解决方案,这是甚至很难访问 org.quartz.Scheduler (参见 JBoss AS中的QuartzScheduler注入6 )。

I didn't find any solutions for this, it's even hard to get access to the org.quartz.Scheduler (see QuartzScheduler injection in JBoss AS 6).

下一个问题是创建新的工作,我按照教程 http://www.quartz-scheduler.org/docs/tutorial/TutorialLesson02.html

The next problem is the creation of new Jobs, I followed the tutorial 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 run now, and then every 40 seconds
  Trigger trigger = newTrigger()
      .withIdentity("myTrigger", "group1")
      .startNow()
      .withSchedule(simpleSchedule()
          .withIntervalInSeconds(40)
          .repeatForever())            
      .build();

  // Tell quartz to schedule the job using our trigger
  sched.scheduleJob(job, trigger);

但似乎 org.quartz.JobBuilder 不适用于JBoss6。如果我在启动时手动添加quartz-dependency有错误(类加载问题)。定义了这个工件(没有明确使用Quartz):

But it seems the org.quartz.JobBuilder is not available for JBoss6. If i manually add the quartz-dependency have errors on startup (class loading issues). This artifacts are defined (without explicitly using Quartz):

<dependency>
    <groupId>org.jboss.jbossas</groupId>
    <artifactId>jboss-as-client</artifactId>
    <version>6.0.0.Final</version>
    <type>pom</type>
    <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>org.jboss.security</groupId>
            <artifactId>jbosssx-client</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.jboss.security</groupId>
            <artifactId>jbosssx</artifactId>
        </exclusion> 
    </exclusions>
</dependency>
    <dependency>
    <groupId>org.jboss.spec</groupId>
    <artifactId>jboss-javaee-6.0</artifactId>
    <version>1.0.0.Final</version>
    <type>pom</type>
    <scope>provided</scope>
</dependency>


推荐答案

看来你正在关注Quartz 2.0.x教程。您是否尝试过 Quartz 1.x教程

It seems you are following Quartz 2.0.x tutorial. Have you tried Quartz 1.x tutorial?

JBoss 6提供的版本是Quartz 1.8.3,并且有重要的 Quartz 2.x中的API更改

The version provided with JBoss 6 is Quartz 1.8.3, and there are significant API changes in Quartz 2.x.

这篇关于如何在JBoss6中动态添加Quartz作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆