Search in sources :

Example 1 with MemoryConfig

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");
}
Also used : AssetStorageService(org.openremote.manager.asset.AssetStorageService) Server(io.moquette.broker.Server) MemoryConfig(io.moquette.broker.config.MemoryConfig)

Aggregations

Server (io.moquette.broker.Server)1 MemoryConfig (io.moquette.broker.config.MemoryConfig)1 AssetStorageService (org.openremote.manager.asset.AssetStorageService)1