10
votes

The Spring's DefaultMessageListenerContainer (DMLC) has concurrentConsumer and taskExecutor property. The taskExecutor bean can be given corePoolSize property. What is then the difference between specifying concurrentConsumer and corePoolSize ? When concurrentConsumer property is defined it means that Spring will create specified number of consumer/messageListeners to process the message. When does corePoolSize comes into picture ?

Code snippet

<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>
1

1 Answers

0
votes

According to 4.3.6 version, the taskExecutor contains instances of AsyncMessageListenerInvoker which responsible for message processing. corePoolSize is a number of physical threads in the defined pool, while concurrentConsumer is a number of tasks in this pool. I guess this abstraction was designed for more flexible control.