@Before public void startBroker() throws Exception { broker = new BrokerService(); broker.setPersistent(false); TransportConnector connector = broker.addConnector(new TransportConnector()); connector.setUri(new URI("tcp://0.0.0.0:0")); connector.setName("tcp"); broker.start(); broker.waitUntilStarted(); brokerConnectURI = broker.getConnectorByName("tcp").getConnectUri(); }
@Override protected void setUp() throws Exception { broker = createBroker(); broker.start(); broker.waitUntilStarted(); resourceProvider = getJmsResourceProvider(); topic = resourceProvider.isTopic(); // We will be using transacted sessions. setSessionTransacted(); connectionFactory = newConnectionFactory(); reconnect(); }
@Before public void setUp() throws Exception { brokerService = new BrokerService(); brokerService.setPersistent(false); brokerService.setUseJmx(true); String connectionUri = brokerService.addConnector("tcp://localhost:0").getPublishableConnectString(); brokerService.start(); brokerService.waitUntilStarted(); ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(connectionUri); final Connection conn = connectionFactory.createConnection(); try { conn.start(); final Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); final Destination queue = session.createQueue(testQueueName); final Message toSend = session.createMessage(); toSend.setStringProperty("foo", "bar"); final MessageProducer producer = session.createProducer(queue); producer.send(queue, toSend); } finally { conn.close(); } }
@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()); } }
public void start() { broker = new BrokerService(); try { broker.setUseJmx(false); broker.setPersistent(false); transportConnector = broker.addConnector(connectorUrl); broker.start(true); broker.waitUntilStarted(); } catch (Exception e) { throw new RuntimeException(e); } }
@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()); } }
public void startProvider () { BrokerService brokerService = getProvider(); if (brokerService != null) { log.info("JMS Server is already started."); return; } brokerService = new BrokerService(); try { brokerService.setBrokerName(getJmsBrokerName()); brokerService.setPersistent(false); brokerService.setUseJmx(false); brokerService.addConnector(getJmsBrokerUrl()); brokerService.start(); brokerService.waitUntilStarted(); } catch (Exception e) { log.error("Failed to start JMS Server", e); } }
@Given("^Start Broker$") public void start() { if (NO_EMBEDDED_SERVERS) { return; } logger.info("Starting new Broker instance"); try { // test if port is already open if (Ports.isPortOpen(1883)) { throw new IllegalStateException("Broker port is already in use"); } // start the broker System.setProperty(KAHA_DB_DIRECTORY, DEFAULT_KAHA_DB_DIRECTORY); broker = BrokerFactory.createBroker(ACTIVEMQ_XML); broker.setDataDirectory(DEFAULT_DATA_DIRECTORY); logger.info("Setting ActiveMQ data directory to {}", broker.getBrokerDataDirectory()); broker.start(); // wait for the broker if (!broker.waitUntilStarted(Duration.ofSeconds(20).toMillis())) { throw new IllegalStateException("Failed to start up broker in time"); } if (EXTRA_STARTUP_DELAY > 0) { Thread.sleep(Duration.ofSeconds(EXTRA_STARTUP_DELAY).toMillis()); } } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException("Failed to start broker", e); } }
@Before public void startBroker() throws Exception { LOG.info("Finding free network port"); try (ServerSocket socket = new ServerSocket(0)) { port = socket.getLocalPort(); } LOG.info("Starting ActiveMQ brokerService on {}", port); brokerService = new BrokerService(); brokerService.setDeleteAllMessagesOnStartup(true); // use memory persistence for the test: it's faster and don't pollute test folder with KahaDB brokerService.setPersistent(false); brokerService.addConnector("mqtt://localhost:" + port); brokerService.start(); brokerService.waitUntilStarted(); }
broker.start(); if (!broker.waitUntilStarted()) { throw new Exception(broker.getStartException());
tmp.deleteOnExit(); BrokerService brokerService = new BrokerService(); brokerService.setBrokerName("localhost"); brokerService.setDeleteAllMessagesOnStartup(true); .addConnector("amqp://0.0.0.0:" + PORT + "?transport.transformer=jms" + "&transport.socketBufferSize=65536&ioBufferSize=8192"); connector.setName("amqp"); brokerService.start(); brokerService.waitUntilStarted();
broker.start(); if (!broker.waitUntilStarted()) { throw new Exception(broker.getStartException());
/** * Start the embedded ActiveMQ broker, blocking until the broker has successfully started. * * The broker will normally be started by JUnit using the before() method. This method allows the broker to * be started manually to support advanced testing scenarios. */ public void start() { try { this.configure(); brokerService.start(); internalClient = new InternalClient(); internalClient.start(); } catch (Exception ex) { throw new RuntimeException("Exception encountered starting embedded ActiveMQ broker: {}" + this.getBrokerName(), ex); } brokerService.waitUntilStarted(); }
broker.start(); if (!broker.waitUntilStarted()) { throw new Exception(broker.getStartException());
public void startBroker() throws Exception { if (brokerService != null && brokerService.isStarted()) { throw new IllegalStateException("Broker already started."); } brokerService = createBroker("localhost", true); brokerService.start(); brokerService.waitUntilStarted(); }
@Override public void run() { Thread.currentThread().setContextClassLoader(ActiveMQResourceAdapter.class.getClassLoader()); try { //Start before returning - this is known to be safe. if (!bs.isStarted()) { Logger .getInstance(LogCategory.OPENEJB_STARTUP, ActiveMQ5Factory.class) .getChildLogger("service") .info("Starting ActiveMQ BrokerService"); bs.start(); } bs.waitUntilStarted(); //Force a checkpoint to initialize pools Logger .getInstance(LogCategory.OPENEJB_STARTUP, ActiveMQ5Factory.class) .getChildLogger("service") .info("Starting ActiveMQ checkpoint"); bs.getPersistenceAdapter().checkpoint(true); started.set(true); } catch (final Throwable t) { throwable = t; } } };
@Override public void run() { Thread.currentThread().setContextClassLoader(ActiveMQResourceAdapter.class.getClassLoader()); try { //Start before returning - this is known to be safe. if (!bs.isStarted()) { Logger .getInstance(LogCategory.OPENEJB_STARTUP, ActiveMQ5Factory.class) .getChildLogger("service") .info("Starting ActiveMQ BrokerService"); bs.start(); } bs.waitUntilStarted(); //Force a checkpoint to initialize pools Logger .getInstance(LogCategory.OPENEJB_STARTUP, ActiveMQ5Factory.class) .getChildLogger("service") .info("Starting ActiveMQ checkpoint"); bs.getPersistenceAdapter().checkpoint(true); started.set(true); } catch (final Throwable t) { throwable = t; } } };
broker.start(); broker.waitUntilStarted(); brokers.put(pid, broker); } catch (Exception e) {
server.getBroker().start(); info("Broker %s has started.", name); server.getBroker().waitUntilStarted(); server.getBroker().addShutdownHook(new Runnable() { @Override
server.getBroker().start(); LOG.info("Broker " + name + " has started."); server.getBroker().waitUntilStarted(); server.getBroker().addShutdownHook(new Runnable() { @Override