Hi,

This is my (simple) setup: A producer sends messages to a queue managed by
ActiveMQ V5.3.1. The goal is to allow concurrent MessageListener objects to
consume messages. For this the DefaultMessageListenerContainer in the Spring
Config File (see below) contains the property 'concurrentConsumers' and the
property 'brokerURL' of ActiveMQConnectionFactory has the prefetch extension
set to 0. But it seems as if only one thread is reading from the queue - as
you can see from the following log snippet

...
2010-05-04 13:17:06,752 INFO  [jmsContainer-84
transport.activemq.ActiveMQMessageListenerImpl.onMessage()] called
2010-05-04 13:17:07,252 INFO  [jmsContainer-84
transport.activemq.ActiveMQMessageListenerImpl.onMessage()] called
...

I would be glad if you could give me a hint on how to configure concurrent
consumers properly, thank you.

Cheerio,
Merck

Message Listener:
---
public class ActiveMQMessageListenerImpl implements MessageListener {
  private static final Logger log =
Logger.getLogger(ActiveMQMessageListenerImpl.class);
  public void onMessage(Message msg) {
    log.info("called");
    try { Thread.sleep(500); }catch(Exception e) {}
  }
}

Spring Config File:
---
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans";
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
       xmlns:jms="http://www.springframework.org/schema/jms";
       xmlns:p="http://www.springframework.org/schema/p";
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/jms
http://www.springframework.org/schema/jms/spring-jms-3.0.xsd";>

  <!-- A JMS connection factory for ActiveMQ -->
  <bean id="connectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL"
value="tcp://localhost:61616?jms.prefetchPolicy.queuePrefetch=0"/>
  </bean>

  <!-- this is the Message Driven POJO (MDP) -->
  <bean id="messageListener"
class="transport.activemq.ActiveMQMessageListenerImpl" />

  <!-- and this is the message listener container -->
  <bean id="jmsContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    <property name="connectionFactory" ref="connectionFactory"/>
    <property name="destinationName" value="read-q"/>
    <property name="messageListener" ref="messageListener" />
    <property name="concurrentConsumers" value="100"/>
  </bean>
</beans>
-- 
View this message in context: 
http://old.nabble.com/Spring---concurrent-consumers-tp28446184p28446184.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to