Thanks, Dave! It seems as though the cacheLevel setting did the trick.
The pooled connection factory on the other hand resulted in no messages arriving on the receiver side. I admit that I was too lazy to find out if they had arrived at the queue at all. (Again I trust the JmsTemplate to report of an exception had this happened) Instead I just reverted back to the org.springframework.jms.connection.SingleConnectionFactory. And now the test passes. Dave Stanley wrote: > > 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 <[EMAIL PROTECTED]> 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. >> >> > > -- View this message in context: http://www.nabble.com/Lost-messages----not-all-messages-sent-to-the-queue-are-delivered-to-the-message-receiver-tp17804229p17810453.html Sent from the ActiveMQ - User mailing list archive at Nabble.com.