JmsTemplate - define concurrency per queue?

a 夏天 提交于 2019-12-13 19:24:42

问题


So far i've only been able to find concurrency setting in the jms connection factory:

<jms:listener-container connection-factory="myConnectionFactory"
                    task-executor="myTaskExecutor"
                    destination-resolver="myDestinationResolver"
                    transaction-manager="myTransactionManager"
                    concurrency="10">

Is it possible to configure the number of consumers for a single queue? i.e something like:

    <jms:listener destination="playerStatsQueue" ref="playerStatsService"
        method="onMessage" concurrency="100" />

Thanks!~


回答1:


Do not use the namespace but an abstract parent DefaultMessageListenerContainer and create one child instance per listener. That way you can tweak all the properties you need.

<bean id="parentContainer" abstract="true"
    class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    <property name="connectionFactory" ref="connectionFactory"/>
    <property name="messageListener" ref="messageListener"/>
    <property name="transactionManager" ref="transactionManager"/>
</bean>

<bean id="playerStatsListener parent="parentContainer">
    <property name="destination" ref="playerStatsQueue"/>
    <property name="listener" ref="playerStatsService"/> 
    <property name="concurrency" value="100"/>         
</bean>


来源:https://stackoverflow.com/questions/21860195/jmstemplate-define-concurrency-per-queue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!