去掉 activemq-pool

This commit is contained in:
shuzheng 2016-11-25 14:42:44 +08:00
parent f0e00693c3
commit 41055caba1
6 changed files with 21 additions and 23 deletions

View File

@ -9,13 +9,9 @@
<bean id="activeMqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${AvtiveMQ.brokerURL}"/>
</bean>
<!--<bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory">-->
<!--<property name="connectionFactory" ref="activeMqConnectionFactory"/>-->
<!--<property name="maxConnections" value="10"/>-->
<!--</bean>-->
<bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory" ref="activeMqConnectionFactory"/>
<property name="sessionCacheSize" value="100"/>
<!--<property name="sessionCacheSize" value="100"/>-->
</bean>
<!-- 点对点队列 -->
<bean id="defaultQueueDestination" class="org.apache.activemq.command.ActiveMQQueue">
@ -27,7 +23,7 @@
</bean>
<!-- 消费者 -->
<bean id="defaultQueueMessageListener" class="com.zheng.cms.mq.jms.defaultQueueMessageListener"/>
<bean id="defaultQueueMessageListener" class="com.zheng.cms.jms.defaultQueueMessageListener"/>
<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="connectionFactory"/>
<property name="destination" ref="defaultQueueDestination"/>

View File

@ -10,9 +10,17 @@
<!-- 线程池维护线程的最大数量默认为Integer.MAX_VALUE -->
<property name="maxPoolSize" value="1000" />
<!-- 线程池所使用的缓冲队列,一般需要设置值>=notifyScheduledMainExecutor.maxNum默认为Integer.MAX_VALUE -->
<property name="queueCapacity" value="200" />
<property name="queueCapacity" value="20000" />
<!-- 线程池维护线程所允许的空闲时间默认为60s -->
<property name="keepAliveSeconds" value="300" />
<!-- 线程池对拒绝任务无线程可用的处理策略目前只支持AbortPolicy、CallerRunsPolicy默认为后者 -->
<property name="rejectedExecutionHandler">
<!-- AbortPolicy:直接抛出java.util.concurrent.RejectedExecutionException异常 -->
<!-- CallerRunsPolicy:主线程直接执行该任务,执行完之后尝试添加下一个任务到线程池中,可以有效降低向线程池内添加任务的速度 -->
<!-- DiscardOldestPolicy:抛弃旧的任务、暂不支持;会导致被丢弃的任务无法再次被执行 -->
<!-- DiscardPolicy:抛弃当前任务、暂不支持;会导致被丢弃的任务无法再次被执行 -->
<bean class="java.util.concurrent.ThreadPoolExecutor$CallerRunsPolicy" />
</property>
</bean>
</beans>

View File

@ -5,7 +5,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

View File

@ -9,14 +9,11 @@
<bean id="activeMqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${AvtiveMQ.brokerURL}"/>
</bean>
<!--<bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory">-->
<!--<property name="connectionFactory" ref="activeMqConnectionFactory"/>-->
<!--<property name="maxConnections" value="10"/>-->
<!--</bean>-->
<bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory" ref="activeMqConnectionFactory"/>
<property name="sessionCacheSize" value="100"/>
</bean>
<!-- 点对点队列 -->
<bean id="defaultQueueDestination" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg index="0" value="com.zheng.cms.queue.default"/>

View File

@ -10,9 +10,17 @@
<!-- 线程池维护线程的最大数量默认为Integer.MAX_VALUE -->
<property name="maxPoolSize" value="1000" />
<!-- 线程池所使用的缓冲队列,一般需要设置值>=notifyScheduledMainExecutor.maxNum默认为Integer.MAX_VALUE -->
<property name="queueCapacity" value="200" />
<property name="queueCapacity" value="20000" />
<!-- 线程池维护线程所允许的空闲时间默认为60s -->
<property name="keepAliveSeconds" value="300" />
<!-- 线程池对拒绝任务无线程可用的处理策略目前只支持AbortPolicy、CallerRunsPolicy默认为后者 -->
<property name="rejectedExecutionHandler">
<!-- AbortPolicy:直接抛出java.util.concurrent.RejectedExecutionException异常 -->
<!-- CallerRunsPolicy:主线程直接执行该任务,执行完之后尝试添加下一个任务到线程池中,可以有效降低向线程池内添加任务的速度 -->
<!-- DiscardOldestPolicy:抛弃旧的任务、暂不支持;会导致被丢弃的任务无法再次被执行 -->
<!-- DiscardPolicy:抛弃当前任务、暂不支持;会导致被丢弃的任务无法再次被执行 -->
<bean class="java.util.concurrent.ThreadPoolExecutor$CallerRunsPolicy" />
</property>
</bean>
</beans>

View File

@ -97,11 +97,6 @@
<version>${mybatis-ehcache.version}</version>
</dependency>
<!-- 数据库 -->
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
@ -183,11 +178,6 @@
<artifactId>activemq-core</artifactId>
<version>5.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-pool</artifactId>
<version>5.7.0</version>
</dependency>
<!-- servlet -->
<dependency>
<groupId>javax.servlet</groupId>