Assign targetExecutor property to Spring DefaultMessageListenerContainer

Spring DefaultMessageListenerContainer (DMLC) has concurrentConsumer and taskExecutor . The taskExecutor bean can be set to the corePoolSize property. What is the difference between specifying concurrentConsumer and corePoolSize? When the concurrentConsumer property is defined, this means that Spring will create the specified number of users / message handlers to process the message. When does a corePoolSize image enter an image?

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> 
+8
spring spring-jms
source share
1 answer

According to version 4.3.6, taskExecutor contains instances of AsyncMessageListenerInvoker , which are responsible for processing messages. corePoolSize is the number of physical threads in a particular pool, and concurrentConsumer is the number of tasks in this pool. I assume that this abstraction was designed for more flexible management.

0
source share

All Articles