move the calls to "waitUntilStarted" so they're *after* the calls to
start the master and slave, should do the trick...

On Fri, Jun 24, 2011 at 3:55 PM, Vijay <vijayender.band...@gmail.com> wrote:
> For Junit testing failover , I want to start Master/slave instances with
> following piece of code. After Master starts, it hangs forever.  If I make
> waitForSlave=true, seems to be working. But I want to test it with wait for
> slave on..Pls. help.
>
> LOG
> -----
> INFO  [main] - Refreshing
> org.apache.xbean.spring.context.ResourceXmlApplicationContext@bd0108:
> startup date [Fri Jun 24 15:45:49 EDT 2011]; root of context hierarchy
> INFO  [main] - Loading XML bean definitions from class path resource
> [master.xml]
> INFO  [main] - Pre-instantiating singletons in
> org.springframework.beans.factory.support.DefaultListableBeanFactory@1a99561:
> defining beans
> [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,org.apache.activemq.xbean.XBeanBrokerService#0];
> root of factory hierarchy
> INFO  [main] - PListStore:activemq-data\master\tmp_storage started
> INFO  [main] - Using Persistence Adapter:
> KahaDBPersistenceAdapter[C:\master_slave_prototype\activemq-data\master\KahaDB]
> INFO  [main] - Persistence store purged.
> INFO  [main] - ActiveMQ 5.5.0 JMS Message Broker (master) is starting
> INFO  [main] - For help or more information please see:
> http://activemq.apache.org/
> INFO  [main] - Listening for connections at: tcp://HDC00020891:61616
> INFO  [main] - Connector tcp://0.0.0.0:61616 Started
>
> <<After this I could not see logs for Master/Slave started >>
>
> Code
> ------
>
> public void testMasterSlave(){
>
>                 BrokerFactoryBean masterBrokerFactory = new 
> BrokerFactoryBean(new
> ClassPathResource("master.xml"));
>         masterBrokerFactory.afterPropertiesSet();
>         final BrokerService masterBroker = masterBrokerFactory.getBroker();
>
>         BrokerFactoryBean slaveBrokerFactory = new BrokerFactoryBean(new
> ClassPathResource("slave.xml"));
>             slaveBrokerFactory.afterPropertiesSet();
>             final BrokerService slaveBroker = slaveBrokerFactory.getBroker();
>
>             masterBroker.start();
>             masterBroker.waitUntilStarted();
>             LOG.info("Master started ...");
>
>             slaveBroker.start();
>             slaveBroker.waitUntilStarted();
>             LOG.info("Slave started ...");
>
>              //Stop Master
>             masterBroker.stop();
>             masterBroker.waitUntilStopped();
>
>             assertTrue("Slave became master now ?", !slaveBroker.isSlave());
>
>
> }
> Master.xml
> ------------
>
>  <broker brokerName="master" useJmx="false" persistent="true"
> waitForSlave="true" deleteAllMessagesOnStartup="true"
> xmlns="http://activemq.apache.org/schema/core";>
>
>   <transportConnectors>
>     <transportConnector uri="tcp://localhost:61616"/>
>   </transportConnectors>
>
>  </broker>
>
> Slave.xml
> -----------
>
>  <broker brokerName="slave" deleteAllMessagesOnStartup="true" useJmx="false"
> masterConnectorURI="tcp://localhost:61616?wireFormat.maxInactivityDurationInitalDelay=90000"
> persistent="true" xmlns="http://activemq.apache.org/schema/core";>
>   <transportConnectors>
>     <transportConnector uri="tcp://localhost:61617"/>
>   </transportConnectors>
>
>  </broker>
>
> --
> View this message in context: 
> http://activemq.2283324.n4.nabble.com/Junit-Testing-Master-Slave-Program-Hangs-forever-tp3623477p3623477.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>

Reply via email to