spring-dtms.xml 2.52 KB
<?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:tx="http://www.springframework.org/schema/tx"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:task="http://www.springframework.org/schema/task"
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
    		http://www.springframework.org/schema/beans/spring-beans.xsd
       		http://www.springframework.org/schema/context 
     		http://www.springframework.org/schema/context/spring-context.xsd
     		http://www.springframework.org/schema/tx  
			http://www.springframework.org/schema/tx/spring-tx.xsd
			http://www.springframework.org/schema/task
            http://www.springframework.org/schema/task/spring-task.xsd"
       default-autowire="byName">
	<context:component-scan base-package="com.b2c.dtms"/>
	<!-- 启用对事务的注解支持 -->
	<tx:annotation-driven transaction-manager="transactionManager" />
	
	<!--<task:executor id="executor" pool-size="5" /> --> 
    <!-- <task:scheduler id="scheduler" pool-size="10" />   -->
    <!-- <task:annotation-driven executor="executor" scheduler="scheduler" />-->
    
    <bean id="dtmsMessageExecutor" class="com.b2c.dtms.schedule.DtmsMessageScheduleExecutor" init-method="init">
        <property name="scheduleTaskFactory" ref="scheduleTaskFactory"/>
        <property name="dtmsMessageService" ref="dtmsMessageService"/>
        <property name="startRow" value="0"/>
        <property name="pageSize" value="50"/>
        <!--初始线程数-->
        <property name="corePoolSize" value="60"/>
        <!--极限线程数,初始线程不够用时 申请新的现场-->
        <property name="maximumPoolSize" value="240"/>
        <!--30秒   配合allowCoreThreadTimeOut参数-->
        <property name="keepAliveTime" value="60"/>
    </bean>
    
    <!--单线程就可以了-->
    <bean id="dtmsMessageMonitor" class="com.b2c.dtms.schedule.DtmsMessageMonitorExecutor" init-method="init">
        <property name="dtmsMessageService" ref="dtmsMessageService"/>
        <property name="startRow" value="0"/>
        <property name="pageSize" value="50"/>
    </bean>
    
    <task:scheduled-tasks>
       <!--2秒钟执行一次-->
       <task:scheduled ref="dtmsMessageExecutor" method="execute" cron="0/10 * * * * ?" />
       <!--10秒钟执行一次-->
       <task:scheduled ref="dtmsMessageMonitor" method="execute" cron="0/20 * * * * ?"/>
    </task:scheduled-tasks>
</beans>