Hello,

Springs CachingConnectionFactory also caches consumers by default [1]. ActiveMQ 
prefetches messages to consumers and if there are multiple consumers in the 
cache of the CachingConnectionFactory you are not guaranteed to consume all 
messages.
Turn off consumer caching in the CachingConnectionFactory and re-test again. 
I would hope the problem is gone.


Regards,

Torsten Mielke
tmielke.blogspot.com

[1] 
http://docs.spring.io/spring/docs/3.0.5.RELEASE/api/org/springframework/jms/connection/CachingConnectionFactory.html#isCacheConsumers()


On 14 Jan 2014, at 09:47 am, Ayelet <aye...@netomedia.com> wrote:

> Hi, 
> 
> We're trying to set up ActiveMQ 5.9.0 as a message broker using JMS topics,
> but we're having some issues with the consumption of the messages. 
> 
> For testing purposes, we have a simple configuration of 1 topic, 1 event
> producer, and 1 consumer. We send 10 messages one after the other, but every
> time we run the application, 1-3 of these messages are not consumed! The
> other messages are consumed and processed fine. 
> Apparently, the solution is to define durable topics, but we couldn't find a
> comprehensive example of how to do that in the spring xmls. 
> This is our current configuration: 
> 
> <bean id="connectionFactory"
> class="com.atomikos.jms.AtomikosConnectionFactoryBean" 
>    init-method="init" destroy-method="close">
>    <property name="uniqueResourceName" value="amq" />
>    <property name="xaConnectionFactory">
>        <bean class="org.apache.activemq.spring.ActiveMQXAConnectionFactory" 
>            p:brokerURL="${activemq_url}" />
>    </property>
>    <property name="maxPoolSize" value="10" />
>    <property name="localTransactionMode" value="false" />
> </bean>
> 
> <bean id="cachedConnectionFactory" 
>    class="org.springframework.jms.connection.CachingConnectionFactory">
>    <property name="targetConnectionFactory" ref="connectionFactory" />
> </bean>
> 
> 
> <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
>    <property name="connectionFactory" ref="cachedConnectionFactory" />
>    <property name="sessionTransacted" value="true" />
>    <property name="pubSubDomain" value="true"/>
> </bean>
> 
> <bean id="testTopic" class="org.apache.activemq.command.ActiveMQTopic">
>    <constructor-arg value="test.topic" />
> </bean>
> 
> 
> <jms:listener-container destination-type="topic" 
>    connection-factory="connectionFactory"
> transaction-manager="transactionManager" 
>    acknowledge="transacted" concurrency="1">
>    <jms:listener destination="test.topic" ref="testReceiver" 
>        method="receive" />
> </jms:listener-container>
> 
> Can anyone please help and provide an example/tutorial? 
> Thanks! :) 
> 
> 
> 
> --
> View this message in context: 
> http://activemq.2283324.n4.nabble.com/Spring-JMS-durable-topics-tp4676266.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.



Reply via email to