use of io.moquette.broker.config.MemoryConfig in project openremote by openremote.
the class MqttBrokerService method start.
@Override
public void start(Container container) throws Exception {
AssetStorageService assetStorageService = container.getService(AssetStorageService.class);
Properties properties = new Properties();
properties.setProperty(BrokerConstants.HOST_PROPERTY_NAME, host);
properties.setProperty(BrokerConstants.PORT_PROPERTY_NAME, String.valueOf(port));
properties.setProperty(BrokerConstants.ALLOW_ANONYMOUS_PROPERTY_NAME, String.valueOf(true));
List<? extends InterceptHandler> interceptHandlers = Collections.singletonList(new ORInterceptHandler(this, identityProvider, messageBrokerService, timerService));
// Load custom handlers
this.customHandlers = stream(ServiceLoader.load(MQTTHandler.class).spliterator(), false).sorted(Comparator.comparingInt(MQTTHandler::getPriority)).collect(Collectors.toList());
// Start each custom handler
for (MQTTHandler handler : customHandlers) {
try {
handler.start(container);
} catch (Exception e) {
LOG.log(Level.WARNING, "MQTT custom handler threw an exception whilst starting: handler=" + handler.getName(), e);
throw e;
}
}
mqttBroker = new Server();
mqttBroker.startServer(new MemoryConfig(properties), interceptHandlers, null, this, new ORAuthorizatorPolicy(identityProvider, this, assetStorageService, clientEventService));
LOG.fine("Started MQTT broker");
}
Aggregations