I don't see anything wrong I'm afraid. Maybe there's some timing issue
where the close of the connection is a tad asynchronous in some aspect
of closing the broker down properly.

FWIW lots of the test cases in ActiveMQ derive from
EmbeddedBrokerTestSupport which explicitly creates/stops a broker
which might help work around this glitch.

e.g. in your test try creating, before the connection (and stopping
after the connection close) a BrokerService...

http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html

(Another smelly hack is to just fork the jvm for each test case and
only put one test method per class :)

On 7/3/07, Elliotte Harold <[EMAIL PROTECTED]> 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]



--
James
-------
http://macstrac.blogspot.com/

Reply via email to