spring4 quartz2 集群动态任务
2015-10-01 20:17
806 查看
实现定时任务的执行,而且要求定时周期是不固定的。测试地址:http://sms.reyo.cn
生产环境:nginx+tomcat+quartz2.2.1+spring4.2.1 集群。
实现功能:可添加新任务,删除任务,更新任务,暂停任务,恢复任务
任务管理:
![](http://images2015.cnblogs.com/blog/40354/201510/40354-20151001200747105-1171075063.png)
![](http://images2015.cnblogs.com/blog/40354/201510/40354-20151001200842293-206610297.png)
修改任务:
![](http://images2015.cnblogs.com/blog/40354/201510/40354-20151001201115730-1874718944.png)
新增任务:
![](http://images2015.cnblogs.com/blog/40354/201510/40354-20151001201138918-1218473167.png)
![](http://images2015.cnblogs.com/blog/40354/201510/40354-20151001201227980-1702668627.png)
静态任务实现每20秒websocket向客户端发送一文字消息和图片信息。
静态任务测试地址(刷新地址可以看到访问到不同的服务器):http://sms.reyo.cn/socket.html
以下是静态任务配置文件:
生产环境:nginx+tomcat+quartz2.2.1+spring4.2.1 集群。
实现功能:可添加新任务,删除任务,更新任务,暂停任务,恢复任务
任务管理:
![](http://images2015.cnblogs.com/blog/40354/201510/40354-20151001200747105-1171075063.png)
![](http://images2015.cnblogs.com/blog/40354/201510/40354-20151001200842293-206610297.png)
修改任务:
![](http://images2015.cnblogs.com/blog/40354/201510/40354-20151001201115730-1874718944.png)
新增任务:
![](http://images2015.cnblogs.com/blog/40354/201510/40354-20151001201138918-1218473167.png)
![](http://images2015.cnblogs.com/blog/40354/201510/40354-20151001201227980-1702668627.png)
静态任务实现每20秒websocket向客户端发送一文字消息和图片信息。
静态任务测试地址(刷新地址可以看到访问到不同的服务器):http://sms.reyo.cn/socket.html
以下是静态任务配置文件:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd"> <!-- 启动触发器的配置开始 --> <bean name="startQuertz" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref bean="autoBatchTestTrigger" /> <!-- <ref bean="cleanErrorTaskTrigger"/> --> </list> </property> <property name="schedulerName"><value>first</value></property> </bean> <!-- 启动触发器的配置结束 --> <!-- 自动测试任务的配置 --> <bean id="autoBatchTestTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean"> <property name="jobDetail"> <ref bean="autoBatchTestJobDetail" /> </property> <property name="cronExpression"> <value>*/20 * * * * ?</value> </property> </bean> <!-- 调度的配置结束 --> <!-- job的配置开始 --> <bean id="autoBatchTestJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject"> <ref bean="autoBatchTestJob" /> </property> <property name="targetMethod"> <value>autoBatchTestTask</value> </property> </bean> <!-- job的配置结束 --> <!-- 工作的bean --> <bean id="autoBatchTestJob" class="reyo.sdk.websocket.quartz.QuartzTaskManager" /> <!-- 自动测试任务结束 --> </beans>
相关文章推荐
- Java基础知识强化之集合框架笔记07:Collection集合的遍历之迭代器遍历
- Java内存模型之运行时数据区域
- Java环境变量配置
- Java基础知识强化之集合框架笔记06:Collection集合存储自定义对象并遍历的案例
- Java中判断字符串是否为数字的五种方法
- java连接mysql的一个小例子
- [转载] java中静态代码块的用法 static用法详解
- Java基础知识强化之集合框架笔记05:Collection集合的遍历
- Java 中的内存泄露
- java菜鸟1:jdk 安装
- Java基础知识强化之集合框架笔记04:Collection集合的基本功能测试
- Java基础知识强化之集合框架笔记03:Collection集合的功能概述
- springmvc整合mybatis出现Could not autowire field:No matching bean of type错误
- JDK环境变量配置
- 图片爬虫程序 JAVA
- Trie树的java实现
- spring MVC访问静态文件,如jpg,js,css
- for JDK1.5 OR HIGHER
- Spring MVC静态资源处理
- 递归求解数组的和 Java实现