Spring 的DefaultMessageListenerContainer (DMLC) 具有concurrentConsumer和taskExecutor属性。taskExecutor bean 可以被赋予corePoolSize属性。那么指定 concurrentConsumer 和 corePoolSize 有什么区别?定义 concurrentConsumer 属性时,意味着 Spring 将创建指定数量的消费者/消息侦听器来处理消息。corePoolSize 什么时候出现?
代码片段
<bean id="myMessageListener"
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="connectionFactory" />
<property name="destination" ref="myQueue" />
<property name="messageListener" ref="myListener" />
<property name="cacheLevelName" value="CACHE_CONSUMER"/>
<property name="maxConcurrentConsumers" value="10"/>
<property name="concurrentConsumers" value="3"/>
<property name="taskExecutor" ref="myTaskExecutor"/>
</bean>
<bean id="myTaskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor" >
<property name="corePoolSize" value="100"/>
<property name="maxPoolSize" value="100"/>
<property name="keepAliveSeconds" value="30"/>
<property name="threadNamePrefix" value="myTaskExecutor"/>
</bean>