2013-04-10 11 views
8

SpringのDefaultMessageListenerContainer(DMLC)は、concurrentConsumertaskExecutorプロパティを持ちます。 taskExecutor BeanにはcorePoolSizeプロパティを指定できます。次に、concurrentConsumerとcorePoolSizeの指定の違いは何ですか? concurrentConsumerプロパティが定義されている場合、Springが指定された数のconsumer/messageListenersを作成してメッセージを処理することを意味します。 corePoolSizeはどのようなときに現れますか?SpringのDefaultMessageListenerContainerのtaskExecutorプロパティの目的

コードは4.3.6バージョンによる

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

答えて

0

をスニペット、taskExecutorは、メッセージ処理を担当するAsyncMessageListenerInvokerのインスタンスが含まれています。 corePoolSizeは、定義されたプール内の物理スレッドの数です。concurrentConsumerは、このプール内のタスクの数です。私はこの抽象化がより柔軟な制御のために設計されていると思います。

関連する問題