activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vijay <vijayender.band...@gmail.com>
Subject Re: Junit Testing Master/Slave Program Hangs forever..
Date Mon, 27 Jun 2011 17:04:00 GMT
Hope this help others:

I had to start the Master in completely new thread and it works with below
code...

Thread t = new Thread(new Runnable() {
			public void run() {
				try {
					BrokerFactoryBean masterBrokerFactory = new BrokerFactoryBean(new
ClassPathResource("master.xml"));
					masterBrokerFactory.afterPropertiesSet();
					masterBroker = masterBrokerFactory.getBroker();
					masterBroker.start();
					LOG.info("Master started ...");
				} catch (Exception e) {
					LOG.warn("Exception starting master: " + e);
					e.printStackTrace();
				}
			}
		});

		LOG.info("About to start thread for master");
		t.start();

		BrokerFactoryBean slaveBrokerFactory = new BrokerFactoryBean(new
ClassPathResource("slave.xml"));
		slaveBrokerFactory.afterPropertiesSet();
		slaveBroker = slaveBrokerFactory.getBroker();

		slaveBroker.start();
		LOG.info("Slave started ...");

		slaveBroker.waitUntilStarted();
		LOG.info("slaveBroker.waitUntilStarted() completed");

		//give 5 sec for Master to Start
		Thread.sleep(5*1000);
		masterBroker.waitUntilStarted();
		LOG.info("masterBroker.waitUntilStarted() completed");

--
View this message in context: http://activemq.2283324.n4.nabble.com/Junit-Testing-Master-Slave-Program-Hangs-forever-tp3623477p3628248.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message