/** * A helper method to block the caller thread until the broker has fully started * * @param timeout * the amount of time to wait before giving up and returning false. * * @return boolean true if wait succeeded false if broker was not started or was stopped */ public boolean waitUntilStarted(long timeout) { boolean waitSucceeded = isStarted(); long expiration = Math.max(0, timeout + System.currentTimeMillis()); while (!isStarted() && !stopped.get() && !waitSucceeded && expiration > System.currentTimeMillis()) { try { if (getStartException() != null) { return waitSucceeded; } waitSucceeded = startedLatch.await(100L, TimeUnit.MILLISECONDS); } catch (InterruptedException ignore) { } } return waitSucceeded; }
/** * A helper method to block the caller thread until the broker has fully started * * @param timeout * the amount of time to wait before giving up and returning false. * * @return boolean true if wait succeeded false if broker was not started or was stopped */ public boolean waitUntilStarted(long timeout) { boolean waitSucceeded = isStarted(); long expiration = Math.max(0, timeout + System.currentTimeMillis()); while (!isStarted() && !stopped.get() && !waitSucceeded && expiration > System.currentTimeMillis()) { try { if (getStartException() != null) { return waitSucceeded; } waitSucceeded = startedLatch.await(100L, TimeUnit.MILLISECONDS); } catch (InterruptedException ignore) { } } return waitSucceeded; }
/** * A helper method to block the caller thread until the broker has fully started * * @param timeout * the amount of time to wait before giving up and returning false. * * @return boolean true if wait succeeded false if broker was not started or was stopped */ public boolean waitUntilStarted(long timeout) { boolean waitSucceeded = isStarted(); long expiration = Math.max(0, timeout + System.currentTimeMillis()); while (!isStarted() && !stopped.get() && !waitSucceeded && expiration > System.currentTimeMillis()) { try { if (getStartException() != null) { return waitSucceeded; } waitSucceeded = startedLatch.await(100L, TimeUnit.MILLISECONDS); } catch (InterruptedException ignore) { } } return waitSucceeded; }
/** * A helper method to block the caller thread until the broker has fully started * * @param timeout * the amount of time to wait before giving up and returning false. * * @return boolean true if wait succeeded false if broker was not started or was stopped */ public boolean waitUntilStarted(long timeout) { boolean waitSucceeded = isStarted(); long expiration = Math.max(0, timeout + System.currentTimeMillis()); while (!isStarted() && !stopped.get() && !waitSucceeded && expiration > System.currentTimeMillis()) { try { if (getStartException() != null) { return waitSucceeded; } waitSucceeded = startedLatch.await(100L, TimeUnit.MILLISECONDS); } catch (InterruptedException ignore) { } } return waitSucceeded; }
@Override public void before() throws Exception { m_temporaryDirectory = Files.createTempDirectory("activemq-data"); m_broker.setPersistent(false); m_broker.setDataDirectory(m_temporaryDirectory.toString()); m_broker.start(); if (!m_broker.waitUntilStarted()) { throw new Exception("ActiveMQ broker was not started or stopped unexpectedly. Error: " + m_broker.getStartException()); } }
@Override public void before() throws Exception { m_temporaryDirectory = Files.createTempDirectory("activemq-data"); m_broker.setPersistent(false); m_broker.setDataDirectory(m_temporaryDirectory.toString()); m_broker.start(); if (!m_broker.waitUntilStarted()) { throw new Exception("ActiveMQ broker was not started or stopped unexpectedly. Error: " + m_broker.getStartException()); } }
throw new Exception(broker.getStartException());
throw new Exception(broker.getStartException());
throw new Exception(broker.getStartException());