Question

I would like to configure number of consumers for a single queue in jms template. I tried to implement this: JmsTemplate - define concurrency per queue? but in the ActiveMQQueue is stiil shows 1. my messanging context:

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

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

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

    <!-- Listeners -->
    <bean id="playerStatsService" class="com.XXX.service.PlayerStatsService" />
    <!-- Destinations -->
        <bean id="playerStatsQueue" class="org.apache.activemq.command.ActiveMQQueue">
        <constructor-arg value="playerStatsQueue" />

another related question: Is there a difference between the "listener" to "messageListener" property?

Was it helpful?

Solution

In general, you can set concurrentConsumers and maxConcurrentConsumers on the DefaultMessageListenerContainer. The concurrency setting gives this as a convenient range.

But according to the docs

Specify concurrency limits via a "lower-upper" String, e.g. "5-10", or a simple upper limit String, e.g. "10" (the lower limit will be 1 in this case).

So if you just say concurrency=100, it's still equivalent to 1-100, which would explain why you're seeing 1 consumer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top