Refine search
/** * Creates a broker from a URI configuration * * @param brokerURI the URI scheme to configure the broker * @throws Exception */ public static BrokerService createBroker(String brokerURI) throws Exception { return createBroker(new URI(brokerURI)); }
/** * Creates a broker from a URI configuration * * @param brokerURI the URI scheme to configure the broker * @param startBroker whether or not the broker should have its * {@link BrokerService#start()} method called after * construction * @throws Exception */ public static BrokerService createBroker(URI brokerURI, boolean startBroker) throws Exception { if (brokerURI.getScheme() == null) { throw new IllegalArgumentException("Invalid broker URI, no scheme specified: " + brokerURI); } BrokerFactoryHandler handler = createBrokerFactoryHandler(brokerURI.getScheme()); BrokerService broker = handler.createBroker(brokerURI); if (startBroker) { broker.start(); } return broker; }
int waitForStart = -1; CompositeData data = URISupport.parseComposite(location); if (data.getComponents().length == 1 && "broker".equals(data.getComponents()[0].getScheme())) { brokerURI = data.getComponents()[0]; CompositeData brokerData = URISupport.parseComposite(brokerURI); location = new URI("vm://" + host); } else { String config = options.remove("brokerConfig"); if (config != null) { brokerURI = new URI(config); } else { Map<String, Object> brokerOptions = IntrospectionSupport.extractProperties(options, "broker."); broker = brokerFactoryHandler.createBroker(brokerURI); } else { broker = BrokerFactory.createBroker(brokerURI); broker.start(); MDC.put("activemq.broker", broker.getBrokerName()); } catch (URISyntaxException e) { throw IOExceptionSupport.create(e);
if (null == broker || !broker.isStarted()) { final URISupport.CompositeData compositeData = URISupport.parseComposite(new URI(brokerURI.getRawSchemeSpecificPart())); final Map<String, String> params = new HashMap<String, String>(compositeData.getParameters()); final PersistenceAdapter persistenceAdapter; final URI uri = new URI(cleanUpUri(brokerURI.getSchemeSpecificPart(), compositeData.getParameters(), params)); broker = BrokerFactory.createBroker(uri); broker.setUseShutdownHook(false); brokers.put(brokerURI, broker); broker.setPersistenceAdapter(persistenceAdapter); broker.setPersistenceFactory(new ProvidedPersistenceAdapterPersistenceAdapterFactory(persistenceAdapter));
configURI = new URI(DEFAULT_CONFIG_URI); } else { configURI = new URI(brokerURIs.get(0)); broker = BrokerFactory.createBroker(configURI); broker.start(); if (!broker.waitUntilStarted()) { throw new Exception(broker.getStartException());
if (null == broker || !broker.isStarted()) { final URISupport.CompositeData compositeData = URISupport.parseComposite(new URI(brokerURI.getRawSchemeSpecificPart())); final Map<String, String> params = new HashMap<String, String>(compositeData.getParameters()); final PersistenceAdapter persistenceAdapter; final URI uri = new URI(cleanUpUri(brokerURI.getRawSchemeSpecificPart(), compositeData.getParameters(), params)); broker = "broker".equals(uri.getScheme()) ? newDefaultBroker(uri) : BrokerFactory.createBroker(uri); if (plugins != null) { broker.setPlugins(plugins); broker.setSystemUsage(systemUsageInstance);
if (brokerService == null) { if (brokerUri != null) { brokerService = BrokerFactory.createBroker(new URI(brokerUri)); brokerName = brokerService.getBrokerName(); brokerService = new BrokerService(); if (brokerName != null) { brokerService.setBrokerName(brokerName);
public BrokerService createBroker(URI brokerURI) throws Exception { URI uri = new URI(brokerURI.getRawSchemeSpecificPart()); BrokerService broker = BrokerFactory.createBroker(uri); broker.setPersistenceAdapter(persistenceAdapter); } else { MemoryPersistenceAdapter persistenceAdapter = new MemoryPersistenceAdapter(); broker.setPersistenceAdapter(persistenceAdapter);
@Override public void initialize() { super.initialize(); try { if (_config == null) { _broker = new BrokerService(); _broker.setStartAsync(true); _broker.setBrokerName("default"); _broker.setUseJmx(false); _broker.setPersistent(false); _broker.setDataDirectoryFile(new File(System.getProperty("java.io.tmpdir"), "activemq-data")); _broker.addConnector(ActiveMQConnectionFactory.DEFAULT_BROKER_BIND_URL); _broker.setUseShutdownHook(false); } else { _broker = BrokerFactory.createBroker(_config); } _broker.start(); } catch (final Exception e) { throw new RuntimeException(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); } }
@Bean(initMethod = "start", destroyMethod = "stop") @ConditionalOnProperty(prefix = "todo.jms", value = "broker", havingValue = "enabled", matchIfMissing = true) public BrokerService messageBroker() { try { BrokerService messageBroker = BrokerFactory.createBroker(String.format("broker:tcp://%s:%s", brokerHost, brokerPort)); messageBroker.setPersistent(false); messageBroker.setUseJmx(false); return messageBroker; } catch (Exception e) { throw new BeanCreationException("Failed to create embedded message broker", e); } }
public void execute() throws Exception { if (config == null) { throw new Exception("required --config option missing"); } if (file == null) { throw new Exception("required --file option missing"); } System.out.println("Loading: " + config); BrokerFactory.setStartDefault(false); // to avoid the broker auto-starting.. BrokerService broker = BrokerFactory.createBroker(config); BrokerFactory.resetStartDefault(); PersistenceAdapter store = broker.getPersistenceAdapter(); System.out.println("Starting: " + store); store.start(); try { BufferedOutputStream fos = new BufferedOutputStream(new FileOutputStream(file)); try { export(store, fos); } finally { fos.close(); } } finally { store.stop(); } }
/** * Creates a broker from a URI configuration * * @param brokerURI the URI scheme to configure the broker * @throws Exception */ public static BrokerService createBroker(URI brokerURI) throws Exception { return createBroker(brokerURI, false); }
public XBeanBrokerService() { start = BrokerFactory.getStartDefault(); }
int waitForStart = -1; CompositeData data = URISupport.parseComposite(location); if (data.getComponents().length == 1 && "broker".equals(data.getComponents()[0].getScheme())) { brokerURI = data.getComponents()[0]; CompositeData brokerData = URISupport.parseComposite(brokerURI); location = new URI("vm://" + host); } else { String config = options.remove("brokerConfig"); if (config != null) { brokerURI = new URI(config); } else { Map<String, Object> brokerOptions = IntrospectionSupport.extractProperties(options, "broker."); broker = brokerFactoryHandler.createBroker(brokerURI); } else { broker = BrokerFactory.createBroker(brokerURI); broker.start(); MDC.put("activemq.broker", broker.getBrokerName()); } catch (URISyntaxException e) { throw IOExceptionSupport.create(e);
configURI = new URI(DEFAULT_CONFIG_URI); } else { configURI = new URI(brokerURIs.get(0)); broker = BrokerFactory.createBroker(configURI); broker.start(); if (!broker.waitUntilStarted()) { throw new Exception(broker.getStartException());
@Override public void initialize() { super.initialize(); try { if (_config == null) { _broker = new BrokerService(); _broker.setStartAsync(true); _broker.setBrokerName("default"); _broker.setUseJmx(false); _broker.setPersistent(false); _broker.setDataDirectoryFile(new File(System.getProperty("java.io.tmpdir"), "activemq-data")); _broker.addConnector(ActiveMQConnectionFactory.DEFAULT_BROKER_BIND_URL); _broker.setUseShutdownHook(false); } else { _broker = BrokerFactory.createBroker(_config); } _broker.start(); } catch (final Exception e) { throw new RuntimeException(e); } }
public void execute() throws Exception { if (config == null) { throw new Exception("required --config option missing"); } if (file == null) { throw new Exception("required --file option missing"); } System.out.println("Loading: " + config); BrokerFactory.setStartDefault(false); // to avoid the broker auto-starting.. BrokerService broker = BrokerFactory.createBroker(config); BrokerFactory.resetStartDefault(); PersistenceAdapter store = broker.getPersistenceAdapter(); System.out.println("Starting: " + store); store.start(); try { BufferedOutputStream fos = new BufferedOutputStream(new FileOutputStream(file)); try { export(store, fos); } finally { fos.close(); } } finally { store.stop(); } }
/** * Creates a broker from a URI configuration * * @param brokerURI the URI scheme to configure the broker * @throws Exception */ public static BrokerService createBroker(URI brokerURI) throws Exception { return createBroker(brokerURI, false); }
public XBeanBrokerService() { start = BrokerFactory.getStartDefault(); }