title: Embedded broker Active MQ start
body: <p>I wrote a little program that use activemq embedded broker. Program run on one machine successfully  but does not work another one. Both of server have sun os 10 &amp; java 7 and also activemq 5.5.1. I mean with does not work, new BrokerService() constructor call does not return for a while (a couple of minutes). Snippet code is like below. </p>
  
  <p>Thanks for advices..</p>
  
  <pre><code>public static void main(String[] args) {
  
      // .... 
      try {
          p.start("tcp://192.168.4.2:61616");
      } catch (MessagingException e) {
          e.printStackTrace();
      }
      // ....
  
  }
  
  
  public void start(String brokerAddress) throws MessagingException {
      try {
  
          System.out.println("&gt;&gt;&gt; initialize 2");
          broker = new JmsBroker(brokerAddress, brokerAddress.substring(6));
          System.out.println("&gt;&gt;&gt; initialize 3");
          broker.start();
          System.out.println("&gt;&gt;&gt; initialize 4");
  
  
          messageProducer = new JmsProducer(brokerAddress,
                                            "MESSAGING_IF_NAME",
                                            false,
                                            5000);
          System.out.println("&gt;&gt;&gt; initialize 5");
  
      } catch (JMSException e) {
          System.out.println(e);
      }
  
  }
  
  
  public class JmsBroker extends Thread {
  
  private BrokerService       broker;
  private Object              lock;
  private static final Logger logger = LoggerFactory.getLogger(JmsBroker.class);
  private String              connector;
  
  
  public JmsBroker(String jmsAddress, String brokerName) throws MessagingException {
      broker = new BrokerService(); // !!!!! PROBLEM
      broker.setBrokerName(brokerName);
      broker.setUseJmx(true);
      broker.setUseLoggingForShutdownErrors(true);
      broker.setSchedulerSupport(false);
      broker.setPersistent(false);
      connector = jmsAddress;
  
      try {
          System.out.println("&gt;&gt;&gt; s1");
          broker.addConnector(connector);
          System.out.println("&gt;&gt;&gt; s2");
          broker.start(true);
          System.out.println("&gt;&gt;&gt; s3");
  
          while (!broker.isStarted()) {
              Thread.sleep(10);
              System.out.println("BROKER NOT STARTED");
          }
  
          logger.info("JMS BROKER STARTED");
          System.out.println("JMS BROKER STARTED");
      } catch (InterruptedException e) {
          throw new MessagingException(e);
      } catch (Exception e) {
          throw new MessagingException(e);
      }
  }
  
  public void run() {
      try {
          lock = new Object();
          synchronized (lock) {
              lock.wait();
          }
      } catch (Exception e) {
          logger.error("", e);
      }
  }
  
  }
  </code></pre>