It would be interesting to see if setting the async flag = false makes a difference on the vm:// transport: e.g. factory = new ActiveMQConnectionFactory("vm://localhost? broker.persistent=false,async=false");

cheers,

Rob


On Jul 3, 2007, at 5:09 PM, Elliotte Harold wrote:

I have a bunch of ActiveMQ tests that are exhibiting weird behavior. That is, sometimes they pass and sometimes they fail. I can run a suite and see seven failures. Then run those tests individually and watch them all pass.

This suggests to me that I'm not properly initializing the queue in setUp or clearing it out in tearDown. The relevant chunks of code look like this:

public class FooSchedulerTest extends TestCase {

   private ConnectionFactory factory;
   private FooScheduler scheduler;
   private MessageConsumer consumer;
   private MessageProducer producer;
   private Connection connection;
   private FooConfig config;
   private int fooID = 10;
   private Session session;

   protected void setUp() throws Exception {
       factory = new
ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");

       config = new FooConfig();
       config.setFooID(fooID);
       Foo foo = new Foo(config, null);
       scheduler = new FooScheduler(factory, foo, new
LinkedBlockingQueue());
       connection = factory.createConnection();
       Destination dispatcher = new ActiveMQQueue(
FooScheduler.DISPATCHER_QUEUE_NAME );
       Destination callback = new ActiveMQQueue(
FooScheduler.COMPLETED_JOBS_QUEUE_NAME );
       connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
       consumer = session.createConsumer(dispatcher);
       producer = session.createProducer(callback);
       super.setUp();
   }

   protected void tearDown() throws Exception {
       connection.close();
       super.tearDown();
   }

Can anyone see anything I might be doing wrong or forgetting to do?

--
Elliotte Rusty Harold
[EMAIL PROTECTED]



Rob Davies
'Go further faster with Apache Camel!'
http://rajdavies.blogspot.com/



Reply via email to