将 Spring 的 LocalTaskExecutorThreadPool 与 Quartz 结合使用
我尝试将 LocalTaskExecutorThreadPool 与石英一起使用,但是当我尝试将它用作石英任务执行器时,我收到此错误。
错误:
arg.springframework.beans.TypeMismatchException:无法转换类型的属性值 [org.springframework.scheduling.quartz.LocalTaskExecutorThreadPool] 为属性“taskExecutor”所需的类型 [org.springframework.core.task.TaskExecutor]。
Spring Config
<bean id="taskExecutor" class="org.springframework.scheduling.quartz.LocalTaskExecutorThreadPool">
</bean>
<bean id="schedulerTarget" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" scope="singleton" lazy-init="false">
<property name="applicationContextSchedulerContextKey">
<value>applicationContext</value>
</property>
<property name="dataSource">
<ref bean="dataSrcBean"/>
</property>
<property name="transactionManager">
<ref bean="txManager" />
</property>
<property name="taskExecutor">
<ref bean="taskExecutor" />
</property>
<property name="quartzProperties">
<props>
<prop key="org.quartz.jobStore.class">org.springframework.scheduling.quartz.LocalDataSourceJobStore</prop>
<prop key="org.quartz.jobStore.tablePrefix">QRTZ_</prop>
<prop key="org.quartz.jobStore.driverDelegateClass">org.quartz.impl.jdbcjobstore.MSSQLDelegate</prop>
<prop key="org.quartz.jobStore.selectWithLockSQL">SELECT * FROM {0}LOCKS WHERE LOCK_NAME = ?</prop>
<prop key="org.quartz.plugin.shutdownhook.class">org.quartz.plugins.management.ShutdownHookPlugin</prop>
<prop key="org.quartz.plugin.shutdownhook.cleanShutdown">true</prop>
<prop key="org.quartz.scheduler.instanceName">Sched1</prop>
<prop key="org.quartz.scheduler.instanceId">1</prop>
<prop key="org.quartz.scheduler.rmi.export">false</prop>
<prop key="org.quartz.scheduler.rmi.proxy">false</prop>
</props>
</property>
</bean>
这样做的全部目的是让Spring 控制quartz 建立的任何连接。我已经有一个由调度程序使用的 Spring 事务管理器,但调度程序似乎会在我的数据库上留下休眠连接。
特纳克斯
Im trying to use the LocalTaskExecutorThreadPool with quartz but when i try to use it as the quartz taskexecutor I get this error.
ERROR:
arg.springframework.beans.TypeMismatchException: Failed to convert property value of type
[org.springframework.scheduling.quartz.LocalTaskExecutorThreadPool] to required type [org.springframework.core.task.TaskExecutor] for property 'taskExecutor'.
Spring Config
<bean id="taskExecutor" class="org.springframework.scheduling.quartz.LocalTaskExecutorThreadPool">
</bean>
<bean id="schedulerTarget" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" scope="singleton" lazy-init="false">
<property name="applicationContextSchedulerContextKey">
<value>applicationContext</value>
</property>
<property name="dataSource">
<ref bean="dataSrcBean"/>
</property>
<property name="transactionManager">
<ref bean="txManager" />
</property>
<property name="taskExecutor">
<ref bean="taskExecutor" />
</property>
<property name="quartzProperties">
<props>
<prop key="org.quartz.jobStore.class">org.springframework.scheduling.quartz.LocalDataSourceJobStore</prop>
<prop key="org.quartz.jobStore.tablePrefix">QRTZ_</prop>
<prop key="org.quartz.jobStore.driverDelegateClass">org.quartz.impl.jdbcjobstore.MSSQLDelegate</prop>
<prop key="org.quartz.jobStore.selectWithLockSQL">SELECT * FROM {0}LOCKS WHERE LOCK_NAME = ?</prop>
<prop key="org.quartz.plugin.shutdownhook.class">org.quartz.plugins.management.ShutdownHookPlugin</prop>
<prop key="org.quartz.plugin.shutdownhook.cleanShutdown">true</prop>
<prop key="org.quartz.scheduler.instanceName">Sched1</prop>
<prop key="org.quartz.scheduler.instanceId">1</prop>
<prop key="org.quartz.scheduler.rmi.export">false</prop>
<prop key="org.quartz.scheduler.rmi.proxy">false</prop>
</props>
</property>
</bean>
The whole purpose of this is to have Spring control any connection quartz makes. I already have a Spring transaction manager being used by the scheduler but its seems the scheduler will leave sleeping connections on my db.
Thnaks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不应该自己使用
LocalTaskExecutorThreadPool
-SchedulerFactoryBean
在内部使用它来将TaskExecutor
包装在 Quartz 的ThreadPool
接口中。SchedulerFactoryBean
期望注入一个taskExecutor
对象。您需要决定要使用TaskExecutor
的哪种实现。You shouldn't use
LocalTaskExecutorThreadPool
yourself -SchedulerFactoryBean
uses this internally to wrap aTaskExecutor
in Quartz'sThreadPool
interface.SchedulerFactoryBean
expects ataskExecutor
object to be injected. You need to decide which implementation ofTaskExecutor
that you want to use.