jboss6 quartz2.0.2集成配置使用
我的环境是windows 下的。所以路径都写死了。如果是linux‘环境下面的话就得重写了。特别要注意哦
先上mbean 路径jboss/server/all/deploy/schedule-service.xml
<mbean code="org.jboss.varia.scheduler.Scheduler" name="jboss.piosan.util:service=QuartzShedule">
<attribute name="StartAtStartup">true</attribute>
<attribute name="SchedulableClass">com.test.schedule.QuartzSchedule</attribute>
<attribute name="SchedulableArgumentTypes">java.lang.String</attribute>
<attribute name="SchedulableArguments">E:/java/jboss-6.1.0.Final/server/all/deploy/quartzConf/quartz.properties</attribute>
<attribute name="InitialStartDate">NOW</attribute>
<attribute name="SchedulePeriod">1000</attribute>
<attribute name="InitialRepetitions">1</attribute>
</mbean>
对应的quartz配置文件为deploy下的quartzConf/quartz.properties
#============================================================================
# Configure Main Scheduler Properties
#============================================================================
org.quartz.scheduler.instanceName = MyScheduler
org.quartz.scheduler.instanceId = AUTO
org.quartz.scheduler.skipUpdateCheck = true
#============================================================================
# Configure ThreadPool
#============================================================================
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 3
org.quartz.threadPool.threadPriority = 5
#============================================================================
# Configure JobStore
#============================================================================
org.quartz.jobStore.misfireThreshold = 60000
org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
#============================================================================
# Configure Datasources
#============================================================================
#============================================================================
# Configure Plugins
#============================================================================
org.quartz.plugin.triggHistory.class = org.quartz.plugins.history.LoggingJobHistoryPlugin
org.quartz.plugin.jobInitializer.class = org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin
org.quartz.plugin.jobInitializer.fileNames = E:/java/jboss-6.1.0.Final/server/all/deploy/quartzConf/quartz_data.xml
org.quartz.plugin.jobInitializer.failOnFileNotFound = true
org.quartz.plugin.jobInitializer.scanInterval = 120
org.quartz.plugin.jobInitializer.wrapInUserTransaction = false
接下来是quartz_data.xml即上面properties中指定的job配置文件
<?xml version="1.0" encoding="UTF-8"?>
<job-scheduling-data xmlns="http://www.quartz-scheduler.org/xml/JobSchedulingData"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.quartz-scheduler.org/xml/JobSchedulingDatahttp://www.quartz-scheduler.org/xml/job_scheduling_data_1_8.xsd"
version="1.8">
<pre-processing-commands>
<delete-jobs-in-group>*</delete-jobs-in-group> <!-- clear all jobs in scheduler -->
<delete-triggers-in-group>*</delete-triggers-in-group> <!-- clear all triggers in scheduler -->
</pre-processing-commands>
<processing-directives>
<!-- if there are any jobs/trigger in scheduler of same name (as in this file), overwrite them -->
<overwrite-existing-data>true</overwrite-existing-data>
<!-- if there are any jobs/trigger in scheduler of same name (as in this file), and over-write is false, ignore them rather then generating an error -->
<ignore-duplicates>false</ignore-duplicates>
</processing-directives>
<schedule>
<job>
<name>MyJobTest</name>
<job-class>com.test.schedule.TestSchedule</job-class>
<job-data-map>
<entry>
<key>name</key>
<value>someValue</value>
</entry>
<entry>
<key>someOtherKey</key>
<value>someOtherValue</value>
</entry>
</job-data-map>
</job>
<trigger>
<cron>
<name>MyJobTest</name>
<job-name>MyJobTest</job-name>
<misfire-instruction>MISFIRE_INSTRUCTION_FIRE_ONCE_NOW</misfire-instruction>
<cron-expression>0 10/1 * * * ?</cron-expression>
</cron>
</trigger>
</schedule>
</job-scheduling-data>
在这个配置文件中我测试了参数的传递。就是
<job-data-map>
<entry>
<key>name</key>
<value>someValue</value>
</entry>
<entry>
<key>someOtherKey</key>
<value>someOtherValue</value>
</entry>
</job-data-map>
如果不需要可以省略
下面上代码哦
我们是通过jboss的mbean去加载我们的job的所以先来个Schedulable
package com.test.schedule;import java.io.File;
import java.util.Date;import org.jboss.varia.scheduler.Schedulable;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.impl.StdSchedulerFactory;public class QuartzSchedule implements Schedulable{private org.quartz.SchedulerFactory factory=null;private Scheduler sd=null;public QuartzSchedule(String fileName){File file=new File(fileName);if(file.exists()){System.setProperty("QUARTZ",file.getParent());try {factory=new StdSchedulerFactory(fileName);} catch (SchedulerException e) {// TODO Auto-generated catch blocke.printStackTrace();}}else{System.out.println(fileName+"-----------------------");}}public void perform(Date arg0, long arg1) {if(factory!=null){System.out.println("调度任务开始启动!------------");try {sd=factory.getScheduler();sd.start();} catch (SchedulerException e) {// TODO Auto-generated catch blocke.printStackTrace();}System.out.println("Quartz启动完毕");}}}
要实现schedulable接口先初始化SchedulerFactory之后就简单了。启动任务就OK
在当前测试项目中我建立了一个名为MyJobTest的任务代码如下
package com.test.schedule;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
public class TestSchedule implements Job {
public void execute(JobExecutionContext context) throws JobExecutionException {
JobDataMap map=context.getJobDetail().getJobDataMap();
System.out.println("我是调度任务,我正在执行!!!!!!!!!!!!!!!"+map.get("name"));
}
}
ok全部结束注意发布地址是server/all/lib下面。另外我用的是比较新的quartz所以要替换jboss/common/lib
下面的quartz-x.x.jar为quartz-2.0.2.jar quartz-jboss-2.0.2.jar
然后重启看看吧。OK
jboss6 quartz2.0.2集成配置使用相关推荐
- cdh的集成phoenix安装_环境篇:Kylin3.0.1集成CDH6.2.0
环境篇:Kylin3.0.1集成CDH6.2.0 Kylin是什么? Apache Kylin™是一个开源的.分布式的分析型数据仓库,提供Hadoop/Spark 之上的 SQL 查询接口及多维分析( ...
- Tomcat6.0.13下配置Tomcat Administration Web Application
Tomcat 5.5 以后的binary 核心安装版不再集成Tomcat Administration Web Application,需要独立下载安装.而Tomcat 6.0.13的Administ ...
- 热修复框架Tinker的从0到集成之路(转)
转自:http://blog.csdn.net/lisdye2/article/details/54411727 热修复框架Tinker的从0到集成之路 转载请标明出处: http://blog.c ...
- 规则引擎选型及应用 邴越 2017-04-27 16:31:17 浏览614 评论0 HTTPS 模块 配置 string exception void input 规则引擎 摘要: 规则引擎具体执
规则引擎选型及应用 邴越 2017-04-27 16:31:17 浏览614 评论0 HTTPS 模块 配置 string exception void input 规则引擎 摘要: 规则引擎具体执行 ...
- obfuscator-llvm Theos 集成配置
之前我写过一篇文章是关于在 Xcode 里怎么集成配置 obfuscator-llvm obfuscator-llvm Xcode集成配置 有些情况下我们使用 Theos 开发 tweak,需要将 o ...
- IIS 7.0的集成模式和经典模式
IIS7.0中的 Web应用程序有两种配置模式:经典模式和集成模式.经典模式是为了与之前的版本兼容,使用ISAPI扩展来调用ASP.NET运行库,原先运行于 IIS6.0下的Web应用程序迁移到IIS ...
- spring 项目集成配置_Spring重试–与项目集成的方式
spring 项目集成配置 如果您需要在代码中实现健壮的重试逻辑,一种行之有效的方法是使用spring重试库. 我的目的不是要展示如何使用spring retry项目本身,而是要演示将其集成到代码库中 ...
- maven2 + tomcat6 + eclipse集成配置
转载:http://wenku.baidu.com/view/d64147c676eeaeaad1f330d4.html?re=view /* maven2 + tomcat6 + eclipse集成 ...
- 3.Jenkins入门基础使用与Maven+SonarQube集成配置与实践
目录一览: Maven 集成配置与实践 SonarQube 集成配置与实践 WeiyiGeek Blog - 为了能到远方,脚下的每一步都不能少. Tips : 本文章来源 Blog 站点或者 We ...
最新文章
- (转)Sublime Text2 快捷键汇总
- NYOJ 269 VF
- tensorflow中的关键字global_step使用
- python123 app下载_Python 逆向抓取 APP 数据
- 基于ffmpeg和libvlc的视频剪辑、播放器
- 【转】集合类说明及区别
- 6、使用infowindow
- 微服务升级_SpringCloud Alibaba工作笔记0004---认识spring gateway理解新一代网关
- python如何对excel排序_Python操作Excel之分组排序
- 图像局部特征(十四)--MSER特征
- windows7下redis的安装实践
- 漏洞扫描工具AppScan下载网盘
- javascript特效大全
- STM32F103C8T6 点亮LED灯
- [Win32] 窗体暗色模式, C++, WinForm, WPF 使用方法, 判断颜色模式, 响应颜色变更消息, 设置标题栏暗色.
- 网易邮箱添加附件功能原理浅析
- 第四章第六节数据资产盘点-系统现状调研情况
- linux下监测cpu温度,linux下CPU温度监测
- SpringBoot集成MyBatis(微服务)
- append和appendTo的区别以及js中的appendChild用法
热门文章
- Excel中如何转换时间为数字
- uni-app打包安卓apk后无法请求数据
- 各大平台会员卡卷接口源码分享
- scss px转换rem
- 2678v3支持内存频率_E52680V2与E52678V3的区别
- C语言进阶——通讯录模拟实现
- 抽象工厂模式[读书笔记]
- php 记录用户积分,数据库创建 · CLTPHP用户签到积分功能,仿layui签到积分功能 · 看云...
- 柱形图太司空见惯,尝试下圆柱图吧!
- rdp协议编程java_关于Java RDP协议实现远程桌面连接的开源项目properjavardp | 学步园...