论坛首页 Java企业应用论坛

spring3.2.5和quartz2.2.1的集群

浏览 6922 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2013-11-20   最后修改:2013-11-20
spring3.2.5和quartz2.2.1的集群有人弄过么
java.io.NotSerializableException: Unable to serialize JobDataMap for insertion into database because the value of property 'methodInvoker' is not serializable
这问题解决不了,度娘说替换MethodInvokingJobDetailFactoryBean,但是新版本jobdetail貌似变成了接口
<bean id="freshScheduler" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    	<property name="dataSource" ref="ds_postgresql" />
        <property name="applicationContextSchedulerContextKey" value="applicationContextKey" />
    	<property name="configLocation" value="classpath:quartz.properties" />
        <property name="triggers">
            <list>
                <ref local="test3Trigger" />
            </list>
        </property>
    </bean>
    
    <bean id="test3Task" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
        <property name="targetObject" ref="testQuarz" />
        <property name="targetMethod" value="test3" />
    </bean>
    
    <bean id="test3Trigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
       <property name="jobDetail" ref="test3Task" />
       <property name="cronExpression" value="0/10 * * * * ?" />
    </bean>

#========================================================================
# Configure Main Scheduler Properties
#========================================================================
org.quartz.scheduler.instanceName = FreshScheduler 
org.quartz.scheduler.instanceId = AUTO 

#========================================================================
# Configure ThreadPool
#========================================================================
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool 
org.quartz.threadPool.threadCount = 5 
org.quartz.threadPool.threadPriority = 5 
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread = true 

#========================================================================
# Configure JobStore
#========================================================================
org.quartz.jobStore.misfireThreshold = 60000 
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX 
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.PostgreSQLDelegate 
org.quartz.jobStore.tablePrefix = QRTZ_ 
org.quartz.jobStore.isClustered = true 
org.quartz.jobStore.clusterCheckinInterval = 20000 
   发表时间:2013-11-24  
MethodInvokingJobDetailFactoryBean javadoc中已经声明该factoryBean产生的jobDetail是不支持序列化的。如果需要支持序列化需要自己实现自己的job去作为默认实现的wrapper。具体文档
NOTE: JobDetails created via this FactoryBean are <i>not</i>
* serializable and thus not suitable for persistent job stores.</b>
* You need to implement your own Quartz Job as a thin wrapper for each case
* where you want a persistent job to delegate to a specific service method.
0 请登录后投票
   发表时间:2013-11-25   最后修改:2013-11-25
<?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:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:jee="http://www.springframework.org/schema/jee"
	xmlns:p="http://www.springframework.org/schema/p"
	xmlns:task="http://www.springframework.org/schema/task"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       				http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
           			http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
           			http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
           			http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
           			http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">
	<bean id="uploadFileStatServiceImpl" class="com.szibr.workbench.task.biz.service.impl.UploadFileStatServiceImpl">
		<property name="logDao">
			<ref bean="logDao" />
		</property>
		<property name="fileDao">
			<ref bean="fileDao" />
		</property>
	</bean> 
	
	<bean id="jobDetailNews" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> 
		<property name="targetObject" ref="uploadFileStatServiceImpl" /> <!-- 实现类 -->
		<property name="targetMethod" value="queryFileByDate" /> <!-- 执行方法 -->
	</bean> 
 	
	<bean id="cronTriggerNews" class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail" ref="jobDetailNews" />
		<property name="cronExpression" value="0 0 2 ? * SUN " />	<!-- 每个星期日,冷晨2点执行 -->
	</bean>
 	
 	<bean id="jobDetailEmail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> 
		<property name="targetObject" ref="systemTaskService" /> <!-- 实现类 -->
		<property name="targetMethod" value="updateSendEmail" /> <!-- 执行方法 -->
		<property name="concurrent" value="false"/><!-- 是否允许任务并发执行。当值为false时,表示必须等到前一个线程处理完毕后才再启一个新的线程 -->
	</bean> 
 	
	<bean id="cronTriggerEmail" class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail" ref="jobDetailEmail" />
		<property name="cronExpression" value="0 0/5 * * * ? " /> 	<!-- 每5分钟执行一次 -->
	</bean>
 	
 	<!-- 
 	<bean id="jobDetailProjectWorkTime" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> 
		<property name="targetObject" ref="systemTaskService" /> 
		<property name="targetMethod" value="saveProjectWorkTimeEmail" /> 
		<property name="concurrent" value="false"/>
	</bean> 
 	
	<bean id="cronTriggerProjectWorkTime" class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail" ref="jobDetailProjectWorkTime" />
		<property name="cronExpression" value="0 30 17 ? * MON-FRI " /> 	
	</bean>
	 -->
	 
 	<!-- end 生成项目填报邮件内容 -->
 	
 	<!-- 生成工作任务邮件内容 -->
 	<bean id="jobDetailWorktask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> 
		<property name="targetObject" ref="systemTaskService" /> <!-- 实现类 -->
		<property name="targetMethod" value="saveWorkTaskEmail" /> <!-- 执行方法 -->
		<property name="concurrent" value="false"/><!-- 是否允许任务并发执行。当值为false时,表示必须等到前一个线程处理完毕后才再启一个新的线程 -->
	</bean> 
 	
	<bean id="cronTriggerWorktask" class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail" ref="jobDetailWorktask" />
		<property name="cronExpression" value="0 0/20 * ? * MON-FRI " /> 	<!-- 只有周一到周五执行 ,每个20分钟执行一次 -->
	</bean>
 	<!-- end 生成工作任务邮件内容 -->
 	
	<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
		<property name="jobDetails">
			<list>
				<ref bean="jobDetailNews" />
				<ref bean="jobDetailEmail" />
				<!-- <ref bean="jobDetailProjectWorkTime" />  --> <!-- 项目填报,暂不发邮件 ,2013.06.28,李汉瑞 -->
				<ref bean="jobDetailWorktask" />
			</list>
		</property>
		<property name="triggers">
			<list>
				<ref bean="cronTriggerNews" />
				<ref bean="cronTriggerEmail" />
				<!-- <ref bean="cronTriggerProjectWorkTime" /> --> <!-- 项目填报,暂不发邮件 ,2013.06.28,李汉瑞-->
				<ref bean="cronTriggerWorktask" />
			</list>
		</property>
	</bean>
	
</beans>

 

0 请登录后投票
   发表时间:2013-12-13  
如果Dao是在service中动态调用的呢?
  • 大小: 8.5 KB
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics