activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dave Stanley" <dstanl...@gmail.com>
Subject Re: Lost messages - not all messages sent to the queue are delivered to the message receiver
Date Thu, 12 Jun 2008 17:33:47 GMT
I think this may be a problem on the consumer side given you are using the
Spring DMLC with no connection caching. The connection will be recycled
each time, but this can cause problems if your prefetch policy is not
aligned.

Try using a pooled connection factory, also try and set the DMLC cacheLevel
to CACHE_CONSUMER ("3")

<bean id="pooledFactory"
class="org.apache.activemq.pool.PooledConnectionFactory"
destroy-method="stop">
    <property name="connectionFactory">
      <bean class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="tcp://localhost:61616" />
      </bean>
    </property>
    <property name="maxConnections" value="1" />
    <property name="maximumActive" value="1" />
  </bean>

<bean id="simpleMessageListenerContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
 ....
<property name="cacheLevel" value="3" />
....
</bean>

HTH
/Dave

On Thu, Jun 12, 2008 at 12:33 PM, drjava <nabble@zippersnapper.com> wrote:

>
> I am using ActiveMQ embedded in my Junit test.
> I have a JmsMessenger that uses a JmsTemplate to send the messages and a
> MessageReceiver to receive the messages.
> The test goal is to verify that all messages that were sent were also
> received (compare numbers and the actual message objects for equality).
>
> How it works: send out 100 unique messages (using a
> SingleConnectionFactory)
> .
> The MessageReceiver intercepts them and collects them in a List.
> Compare that the total received and sent are equal.
> Compare the received list's items to the sent ones, make sure the messages
> did not get corrupted.
>
> However, on each and every run the test fails on the first assertion -
> comparing the total sent and received numbers.
>
> Moreover this - on each run the total received number is different. (after
> sending is complete the main thread awaits for 1 minute, which I consider a
> long enough time to intercept 100 messages, so that the receiver gets the
> opportunity to catch up)
>
> According to the JmsTemplate all messages are successfully sent (the call
> to
> convertAndSend is surrounded by a try/catch block and no JmsException is
> being caught).
>
> Emvironment details:
> IDE - eclipse 3.3.2
> test runner - Junit 4.4
> ActiveMQ version - 5.1.0
> VM - Java 1.6_0_06
> OS - Windows XP 64bits
> hardware - Dell Intel dual core, 2.66GH, 3.93 GB of RAM
>
> Perhaps I don't fully understand how to best use Active MQ embedded in my
> test. Are there any special settings of the broker's properties I should
> exercise?
>
> I am attaching a few files to support understanding of my test scenario:
>
> spring-config.xml (this configures the jms template and the message
> receiver
> and jms messenger and all the rest)
> http://www.nabble.com/file/p17804229/spring-config.xml spring-config.xml
>
> JmsMessengerTest.java the test class
> http://www.nabble.com/file/p17804229/JmsMessengerTest.java
> JmsMessengerTest.java
>
> MessageReceiver.java
> http://www.nabble.com/file/p17804229/MessageReceiver.java
> MessageReceiver.java
>
> JmsLogMessenger.java
> http://www.nabble.com/file/p17804229/JmsLogMessenger.java
> JmsLogMessenger.java
> --
> View this message in context:
> http://www.nabble.com/Lost-messages----not-all-messages-sent-to-the-queue-are-delivered-to-the-message-receiver-tp17804229p17804229.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message