spring-dtms.xml
2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?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>