spring4 quartz2 集群动态任务

实现定时任务的执行,而且要求定时周期是不固定的。测试地址:http://sms.reyo.cn

生产环境:nginx+tomcat+quartz2.2.1+spring4.2.1 集群。

实现功能:可添加新任务,删除任务,更新任务,暂停任务,恢复任务

任务管理:

spring4 quartz2 集群动态任务

spring4 quartz2 集群动态任务

修改任务:

spring4 quartz2 集群动态任务

新增任务:

spring4 quartz2 集群动态任务

spring4 quartz2 集群动态任务

静态任务实现每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>
上一篇:初学Scala


下一篇:C#中的多线程 - 高级多线程