/** * Initializes {@code broker} and starts it. * @throws Exception if an exception during adding a connector occurs */ public static void startBroker() throws Exception { LOG.info("Starting broker..."); broker = new BrokerService(); broker.addConnector("mqtt://localhost:1883"); broker.setDataDirectory("target"); broker.start(); LOG.info("MQTT broker started"); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { try { LOG.info("Shutting down MQTT broker..."); broker.stop(); } catch (Exception e) { e.printStackTrace(); } } }); }
@Before public void setUp() throws Exception { this.brokerService = new BrokerService(); this.brokerService.addConnector(this.brokerUrl); this.brokerService.setDataDirectory(BROKER_DATA_DIRECTORY); this.brokerService.start(); this.workerApplicationContext = new AnnotationConfigApplicationContext(WorkerConfiguration.class); }
@Before public void setUp() throws Exception { this.brokerService = new BrokerService(); this.brokerService.addConnector(this.brokerUrl); this.brokerService.setDataDirectory(BROKER_DATA_DIRECTORY); this.brokerService.start(); this.embeddedDatabase = new EmbeddedDatabaseBuilder() .addScript("/org/springframework/batch/core/schema-drop-hsqldb.sql") .addScript("/org/springframework/batch/core/schema-hsqldb.sql") .build(); this.workerApplicationContext = new AnnotationConfigApplicationContext(getWorkerConfigurationClass()); }
@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()); } }
@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); } }
broker.setDataDirectory(dataDir); try { broker.addConnector(brokerUrl);
connector.setUri(new URI(getTransportUri())); brokerService.addConnector(connector); brokerService.setDataDirectory(getDataDirectory()); brokerService.setUseShutdownHook(false); brokerService.setUseJmx(false);
broker.addConnector(brokerUrl); if (StringUtils.isNotEmpty(brokerDataDirectory)) { broker.setDataDirectory(brokerDataDirectory);
protected BrokerService createBroker(String name, boolean deleteMessagesOnStartup, Map<String, Integer> portMap) throws Exception { BrokerService brokerService = new BrokerService(); brokerService.setBrokerName(name); brokerService.setDeleteAllMessagesOnStartup(deleteMessagesOnStartup); brokerService.setUseJmx(true); brokerService.getManagementContext().setCreateConnector(false); brokerService.setDataDirectory(DATA_PARENT_DIR + File.separator + "data" + File.separator + name); brokerService.setPersistent(false); brokerService.setSchedulerSupport(false); brokerService.setAdvisorySupport(false); ArrayList<BrokerPlugin> plugins = new ArrayList<BrokerPlugin>(); BrokerPlugin authenticationPlugin = configureAuthentication(); if (authenticationPlugin != null) { plugins.add(authenticationPlugin); } if (!plugins.isEmpty()) { brokerService.setPlugins(plugins.toArray(new BrokerPlugin[0])); } addAdditionalConnectors(brokerService, portMap); return brokerService; }
brokerService.setUseJmx(true); brokerService.getManagementContext().setCreateConnector(false); brokerService.setDataDirectory(tmp.getAbsolutePath()); brokerService.setPersistent(false); brokerService.setSchedulerSupport(false);
wfEventListener.init(conf); broker = new BrokerService(); broker.setDataDirectory(getTestCaseDir()); broker.addConnector(brokerURl); broker.setUseJmx(false); broker.setDataDirectory(getTestCaseDir()); broker.addConnector(brokerURl); broker.setUseJmx(false);
broker.setUseJmx(true); broker.setTmpDataDirectory(tempDir); broker.setDataDirectory(dataDir.toString()); if (brokerConfiguration == null) {
broker.setUseJmx(mBeanServer != null); broker.setTmpDataDirectory(tempDir); broker.setDataDirectory(dataDir.toString()); if (brokerConfiguration == null) {
brokerService.setDataDirectory(getDataDirectory()); KahaDBPersistenceAdapter persistenceAdapter = new KahaDBPersistenceAdapter(); persistenceAdapter.setDirectory(new File(getDataDirectory()));
try { broker.addConnector(brokerURl); broker.setDataDirectory(getTestCaseDir()); broker.setUseJmx(false); broker.start();
broker.setDataDirectory(getTestCaseDir()); broker.setUseJmx(false); broker.start(); broker.setDataDirectory(getTestCaseDir()); broker.setUseJmx(false); broker.start();