activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ron55test <>
Subject All messages are not delivered to slower consumer(fast producer)
Date Mon, 12 Mar 2007 22:42:20 GMT


I've been trying to solve this problem for the last two days without any
luck.  Any help will be appreciated.

I've a producer sending 5 messages (just some string) one after another in a
for-loop.  The consumer is a slow consumer and consumes the messages 1 at a
time at 1 minute interval.  I'm using spring's
DefaultMessageListenerContainer with 1 concurrentConsumer

I'm using JDBC persistence without transaction (but do
CLIENT_ACKNOWLEDGEMENT).  I'm using Spring 2.0, activemq 4.1.

This is what I notice:  The producer is sending the 5 messages 1 after
another.  The messages get stored in the database ( I could query and find
out).  The consumer get the first message and that is it.  The consumer does
not get any more messages. 
In a nutshell, our production scenario is this: 
--our web client will be sending tasks to execute
--We want our consumer to receive the task serially and process and send an
email to the user with success/failure(even if there is an exception)

Here is my code and configuration:

//This our producer
<bean id="asynchronousTaskManager"
class="" >
     <property name="jmsTemplate" ref="jmsQueueTemplate" />

         public void sendMethod()
            for (int i =0 ; i < 5; i++)
                _jmsTemplate.convertAndSend(msg + i);

 <bean id="jmsQueueTemplate"
   <property name="connectionFactory">
    <ref bean="jmsConnectionFactory"/>
   <property name="defaultDestination">
    <ref bean="destination" />
   <property name="receiveTimeout">
      <property name="sessionAcknowledgeModeName" value="AUTO_ACKNOWLEDGE"/>

 <bean id="jmsReceiver" class=""
    <property name="jmsTemplate" ref="jmsQueueTemplate" />

          <bean id="jmsTemplate"
                <property name="connectionFactory" ref="connectionFactory"
                <property name="defaultDestination" ref="destination" />

 <bean id="jmsConnectionFactory"
class="org.apache.activemq.pool.PooledConnectionFactory" >
   <property name="connectionFactory">
     <bean class="org.apache.activemq.ActiveMQConnectionFactory">
       <property name="brokerURL">
       <property name="dispatchAsync">
       <property name="useAsyncSend">

        <bean id="destination" class="org.activemq.message.ActiveMQQueue">
                <constructor-arg value="jmsExample" />

        <bean id="listenerContainer"
                <property name="concurrentConsumers" value="1" />
                <property name="connectionFactory" ref="connectionFactory"
                <property name="destination" ref="destination" />
                <property name="messageListener" ref="jmsReceiver" />
                 <property name="sessionAcknowledgeModeName"

Here is my consumer code:
public class JMSReceiverImpl implements MessageListener
    private JmsTemplate _jmsTemplate;

    public void onMessage(Message msg)
        System.out.println("Inside onMessage ");
        Message recievedMessage = _jmsTemplate.receive();
            String message = ((TextMessage)recievedMessage).getText();
            System.out.println("The received message is: " + message);
        catch (Exception e)

This is my activemq.xml file:


  <broker brokerName="localhost" useJmx="true"
      <jdbcPersistenceAdapter dataSource="#oracle-ds"/>
       <transportConnector name="openwire"
uri="tcp://localhost:61616?jms.prefetchPolicy.all=1" />
  <!-- Oracle DataSource Sample Setup -->
  <bean id="oracle-ds" class="org.apache.commons.dbcp.BasicDataSource"
    <property name="driverClassName"
    <property name="url"
    <property name="username" value="user"/>
    <property name="password" value="pwd"/>
    <property name="poolPreparedStatements" value="true"/>


Any help will be appreciated.
View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message