- 軟件大(dà)小:422KB
- 軟件(jiàn)語言:中(zhōng)文(wén)
- 軟件類型:國產軟件
- 軟件類別:免費軟件 / 編程工(gōng)具
- 更新時間:2017-10-09 16:01
- 運行環境:WinAll, WinXP, Win7, Win8, Win10
- 軟件等級(jí):
- 軟件廠商(shāng):
- 官(guān)方網站:http://www.chithemodel.com/
17.82M/英文(wén)/10.0
31.35M/多國語言(yán)[中文]/5.0
16.13M/多國語言[中文]/6.6
1.45M/中文/10.0
4.60M/中文/8.7
quartz all 1.8.5.jar是(shì)一款非(fēi)常好用的(de)編程工具(jù),功能強大(dà),使(shǐ)用方(fāng)便,有需(xū)要(yào)的朋友不(bú)要錯過了,還等什麽,快約上你的小夥伴,一起來綠色資源(yuán)網下載使用!
在(zài)數據庫中創建Quartz所需表(sql語句可以在quartz-1.8.5\docs\dbTables中找到(dào),這(zhè)裏以(yǐ)oracle數據庫(kù)為(wéi)例):
qrtz_blob_triggers,
qrtz_calendars,
qrtz_cron_triggers,
qrtz_fired_triggers,
qrtz_job_details,
qrtz_job_listeners,
qrtz_locks,
qrtz_paused_trigger_grps,
qrtz_scheduler_state,
qrtz_simple_triggers,
qrtz_triggers,
qrtz_trigger_listeners
加(jiā)入quartz 所需要的(de)包:
放入jboss-4.2.3.GA\server\all\lib下
先(xiān)把jboss自帶的quartz jar刪除掉。包括(quartz-ra.rar)都(dōu)刪除掉。
commons-dbcp-1.3.jar
commons-pool-1.5.4.jar
jta-1.1.jar
log4j-1.2.14.jar
quartz-all-1.8.5.jar
slf4j-api-1.6.0.jar
slf4j-log4j12-1.6.0.jar
3.創建quartz-service.xml文(wén)件(放入jboss-4.2.3.GA\server\all\deploy下),文件內容如(rú)下:
<?xml version="1.0" encoding="UTF-8"?>
<server>
<mbean code="org.quartz.ee.jmx.jboss.QuartzService"
name="user:service=QuartzService,name=QuartzService">
<attribute name="JndiName">Quartz</attribute>
<attribute name="StartScheduler">true</attribute>
<attribute name="Properties">
#============================================================================
# Configure Main Scheduler Properties
#============================================================================
#==========集(jí)群名稱(chēng),每個節(jiē)點的名字都一(yī)樣===========
org.quartz.scheduler.instanceName = quartzjbossdemopartitionName
#==========集群每個(gè)節點ID=======
org.quartz.scheduler.instanceId = AUTO
#============================================================================
# Configure ThreadPool
#============================================================================
#=======線程====
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 25
org.quartz.threadPool.threadPriority = 5
#============================================================================
# Configure JobStore
#============================================================================
org.quartz.jobStore.misfireThreshold = 60000
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.oracle.OracleDelegate
org.quartz.jobStore.dataSource = QUARTZ
org.quartz.jobStore.tablePrefix = QRTZ_
org.quartz.jobStore.isClustered = true
org.quartz.jobStore.clusterCheckinInterval = 30000
#============================================================================
# Configure Datasources
#============================================================================
#=================數據庫(kù)寫(xiě)上自己(jǐ)的數據庫======
org.quartz.dataSource.QUARTZ.driver = oracle.jdbc.driver.OracleDriver
org.quartz.dataSource.QUARTZ.URL = jdbc:oracle:thin:@192.168.111.24:1521:db org.quartz.dataSource.QUARTZ.user = rootmq
org.quartz.dataSource.QUARTZ.password = rootmq
org.quartz.dataSource.QUARTZ.maxConnections = 5
org.quartz.dataSource.QUARTZ.validationQuery=select 0 from dual
</attribute>
</mbean>
</server>
4. java代碼
每一個 Quartz Job 必須有一個實現(xiàn)了 org.quartz.Job 接口的具體類.
public class JbossJob implements Job {
public void execute(JobExecutionContext arg0) throws JobExecutionException {
System.out.println("hello jbossJob .....");
}
}
5. 具體調用(yòng)
public class StartOrCloseScheduler implements Serializable{
/**
*
*/
private static final long serialVersionUID = -2266323478579408291L;
private static Logger myLogger = Logger.getLogger(StartOrCloseScheduler.class);
private static Scheduler sched = null;
/**
* 啟動任務
* jobName: job名稱
* jobGroupName: job組名(míng)稱
* triggerName: trigger名稱(chēng)
* triggerGroupName:trigger組名稱
*/
@SuppressWarnings("rawtypes")
public static void start(String jobName,String jobGroupName,
String triggerName,String triggerGroupName,
Class c, String str) {
try {
InitialContext ctx = new InitialContext();
sched = (Scheduler) ctx.lookup("Quartz");
System.out.println("Scheduler:" + sched);
} catch (NamingException e) {
e.printStackTrace();
}
JobDetail job = new JobDetail(jobName,jobGroupName, c);
System.out.println("JobDetail:" + job);
Trigger trigger = new CronTrigger(triggerName,triggerGroupName);
System.out.println("Trigger:" + trigger);
try {
((CronTrigger) trigger).setcronExpression(str);
sched.scheduleJob(job, trigger);
System.out.println("job:" + job);
sched.start();
} catch (Exception e) {
myLogger.error("開啟一(yī)個任務"+jobName+e.getMessage());
e.printStackTrace();
}
}
/**
* 移除一個任務(wù)
* @param jobName: job名稱(chēng)
* @param jobGroupName: job組名稱
* @param triggerName: trigger名稱
* @param triggerGroupName: trigger組名稱
* @throws SchedulerException
*/
public static void removeJob(String jobName,String jobGroupName,
String triggerName,String triggerGroupName) {
try {
InitialContext ctx = new InitialContext();
sched = (Scheduler) ctx.lookup("Quartz");
} catch (NamingException e) {
e.printStackTrace();
}
try {
//停止(zhǐ)觸發器
sched.pauseTrigger(triggerName,triggerGroupName);
//移除觸(chù)發器
sched.unscheduleJob(triggerName,triggerGroupName);
//刪(shān)除任(rèn)務
sched.deleteJob(jobName,jobGroupName);
} catch (SchedulerException e) {
myLogger.info("移除一個任(rèn)務"+jobName+e.getMessage());
}
}
}
請描述您所(suǒ)遇到的錯(cuò)誤,我們(men)將(jiāng)盡快予以修正(zhèng),謝(xiè)謝(xiè)!
*必填(tián)項,請(qǐng)輸入(rù)內容