use of org.apache.activemq.broker.BrokerService in project tomee by apache.
the class ActiveMQ5Factory method newDefaultBroker.
// forking org.apache.activemq.broker.DefaultBrokerFactory.createBroker() to support network connector properties
private BrokerService newDefaultBroker(final URI uri) throws Exception {
final URISupport.CompositeData compositeData = URISupport.parseComposite(uri);
final Map<String, String> params = new HashMap<String, String>(compositeData.getParameters());
final BrokerService brokerService = newPatchedBrokerService();
IntrospectionSupport.setProperties(brokerService, params);
if (!params.isEmpty()) {
String msg = "There are " + params.size() + " Broker options that couldn't be set on the BrokerService." + " Check the options are spelled correctly." + " Unknown parameters=[" + params + "]." + " This BrokerService cannot be started.";
throw new IllegalArgumentException(msg);
}
if (compositeData.getPath() != null) {
brokerService.setBrokerName(compositeData.getPath());
}
for (final URI component : compositeData.getComponents()) {
if ("network".equals(component.getScheme())) {
brokerService.addNetworkConnector(component.getSchemeSpecificPart());
} else if ("proxy".equals(component.getScheme())) {
brokerService.addProxyConnector(component.getSchemeSpecificPart());
} else {
brokerService.addConnector(component);
}
}
return brokerService;
}
use of org.apache.activemq.broker.BrokerService in project tomee by apache.
the class ActiveMQResourceAdapter method stopImpl.
private void stopImpl() throws Exception {
super.stop();
final Collection<BrokerService> brokers = ActiveMQFactory.getBrokers();
final Iterator<BrokerService> it = brokers.iterator();
while (it.hasNext()) {
final BrokerService bs = it.next();
try {
bs.stop();
bs.waitUntilStopped();
} catch (final Throwable t) {
//Ignore
}
it.remove();
}
stopScheduler();
Logger.getInstance(LogCategory.OPENEJB_STARTUP, ActiveMQResourceAdapter.class).getChildLogger("service").info("Stopped ActiveMQ broker");
}
use of org.apache.activemq.broker.BrokerService in project tomee by apache.
the class BrokerServer method init.
@Override
public void init(final Properties properties) throws Exception {
final String port = properties.getProperty("port", "1527");
final String bind = properties.getProperty("bind");
final String disabled = properties.getProperty("disabled");
this.port = Integer.parseInt(port);
this.disabled = Boolean.parseBoolean(disabled);
host = InetAddress.getByName(bind);
if (this.disabled) {
return;
}
final URI uri = new URI("tcp", null, bind, this.port, null, null, null);
broker = new BrokerService();
broker.setPersistent(false);
broker.addConnector(uri);
}
use of org.apache.activemq.broker.BrokerService in project camel by apache.
the class StompBaseTest method setUp.
@Override
public void setUp() throws Exception {
port = AvailablePortFinder.getNextAvailable(61613);
try {
brokerService = new BrokerService();
brokerService.setPersistent(false);
brokerService.setAdvisorySupport(false);
if (isUseSsl()) {
SslContext sslContext = new SslContext();
sslContext.setSSLContext(getServerSSLContext());
brokerService.setSslContext(sslContext);
brokerService.addConnector("stomp+ssl://localhost:" + getPort() + "?trace=true");
} else {
brokerService.addConnector("stomp://localhost:" + getPort() + "?trace=true");
}
brokerService.start();
brokerService.waitUntilStarted();
super.setUp();
canTest = true;
} catch (Exception e) {
System.err.println("Cannot test due " + e.getMessage() + " more details in the log");
log.warn("Cannot test due " + e.getMessage(), e);
canTest = false;
}
}
use of org.apache.activemq.broker.BrokerService in project storm by apache.
the class MqttBrokerPublisher method startBroker.
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();
}
}
});
}
Aggregations