Class MQTTBrokerService

java.lang.Object
org.apache.camel.builder.BuilderSupport
org.apache.camel.builder.RouteBuilder
org.openremote.manager.mqtt.MQTTBrokerService
All Implemented Interfaces:
org.apache.activemq.artemis.core.server.plugin.ActiveMQServerBasePlugin, org.apache.activemq.artemis.core.server.plugin.ActiveMQServerConnectionPlugin, org.apache.activemq.artemis.core.server.plugin.ActiveMQServerSessionPlugin, org.apache.camel.builder.ModelRoutesBuilder, org.apache.camel.CamelContextAware, org.apache.camel.Ordered, org.apache.camel.RoutesBuilder, org.apache.camel.spi.HasCamelContext, org.apache.camel.spi.ResourceAware, org.openremote.model.ContainerService

public class MQTTBrokerService extends org.apache.camel.builder.RouteBuilder implements org.openremote.model.ContainerService, org.apache.activemq.artemis.core.server.plugin.ActiveMQServerConnectionPlugin, org.apache.activemq.artemis.core.server.plugin.ActiveMQServerSessionPlugin
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
     
    static final String
     
     
     
     
     
    protected ConcurrentMap<String,org.apache.activemq.artemis.spi.core.protocol.RemotingConnection>
     
    protected ConcurrentMap<String,org.apache.activemq.artemis.spi.core.protocol.RemotingConnection>
     
    protected List<MQTTHandler>
     
    protected com.google.common.cache.Cache<String,org.apache.activemq.artemis.spi.core.protocol.RemotingConnection>
     
    protected ExecutorService
     
    protected String
     
     
    protected static final System.Logger
     
    protected org.openremote.container.message.MessageBrokerService
     
    static final String
     
    static int
     
    static final String
     
    static final String
     
    protected int
     
    static final int
     
     
    protected org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ
     
    protected org.apache.activemq.artemis.core.config.Configuration
     
    protected org.apache.activemq.artemis.api.core.client.ServerLocator
     
    protected org.apache.activemq.artemis.api.core.client.ClientSessionFactory
     
    protected org.openremote.container.timer.TimerService
     
    protected org.openremote.model.util.Debouncer<String>
     
    protected ConcurrentMap<String,List<org.openremote.model.PersistenceEvent<org.openremote.model.asset.UserAssetLink>>>
     
    protected final org.apache.activemq.artemis.core.config.WildcardConfiguration
     

    Fields inherited from class org.apache.camel.builder.RouteBuilder

    log

    Fields inherited from interface org.openremote.model.ContainerService

    DEFAULT_PRIORITY, HIGH_PRIORITY, LOW_PRIORITY, MED_PRIORITY

    Fields inherited from interface org.apache.camel.Ordered

    HIGHEST, LOWEST
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    afterCreateConnection(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection connection)
     
    void
    afterCreateSession(org.apache.activemq.artemis.core.server.ServerSession session)
     
    void
    afterDestroyConnection(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection connection)
     
    void
    authenticateConnection(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection connection, String realm, String username, String password)
     
    void
     
    static String
    connectionToString(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection connection)
     
    protected org.apache.activemq.artemis.api.core.client.ClientSession
    Create a client session for communicating with the broker
    boolean
    disconnectSession(String connectionID)
     
    protected void
    doForceDisconnect(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection connection)
     
    org.apache.activemq.artemis.spi.core.protocol.RemotingConnection
     
    static String
    getConnectionIDString(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection connection)
     
     
    int
     
    protected org.apache.activemq.artemis.core.config.WildcardConfiguration
     
    static String
     
    Set<org.apache.activemq.artemis.spi.core.protocol.RemotingConnection>
    Get active connections for the specified user ID
    org.apache.activemq.artemis.core.config.WildcardConfiguration
     
    void
    init(org.openremote.model.Container container)
     
    protected void
    notifyConnectionAuthenticated(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection connection)
     
    void
    onSubscribe(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection connection, String topicStr)
     
    void
    onUnsubscribe(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection connection, String topicStr)
     
    void
    processUserAssetLinkChange(String userID, List<org.openremote.model.PersistenceEvent<org.openremote.model.asset.UserAssetLink>> changes)
     
    void
    start(org.openremote.model.Container container)
     
    void
    stop(org.openremote.model.Container container)
     

    Methods inherited from class org.apache.camel.builder.RouteBuilder

    addLifecycleInterceptor, addRoutes, addRoutesToCamelContext, addTemplatedRoutesToCamelContext, bindToRegistry, bindToRegistry, checkInitialized, configuration, configureRest, configureRests, configureRoute, configureRouteConfiguration, configureRoutes, configureRouteTemplate, configureTemplatedRoute, customize, customize, dataFormat, errorHandler, errorHandler, expression, from, from, from, fromF, fromV, fromV, getBeans, getOrder, getResource, getRestCollection, getRestConfiguration, getRests, getRouteCollection, getRoutes, getRouteTemplateCollection, getTemplatedRouteCollection, initializeCamelContext, intercept, interceptFrom, interceptFrom, interceptSendToEndpoint, loadRoutesBuilder, loadRoutesBuilder, onCompletion, onException, onException, populateBeans, populateOrUpdateRoutes, populateRests, populateRoutes, populateRouteTemplates, populateTemplatedRoutes, populateTransformers, populateValidators, prepareModel, property, propertyInject, removeLifecycleInterceptor, rest, rest, restConfiguration, routeTemplate, setErrorHandlerFactory, setResource, setRestCollection, setRouteTemplateCollection, setTemplatedRouteCollection, templatedRoute, tokenizer, toString, transformer, updateRoutesToCamelContext, validator

    Methods inherited from class org.apache.camel.builder.BuilderSupport

    body, bodyAs, constant, constant, constant, createErrorHandlerBuilder, csimple, csimple, datasonnet, datasonnet, datasonnet, deadLetterChannel, deadLetterChannel, defaultErrorHandler, endpoint, endpoint, exceptionMessage, exchangeProperty, expression, getCamelContext, getContext, getErrorHandlerFactory, hasErrorHandlerFactory, header, java, java, joor, joor, jq, jq, jsonpath, jsonpath, jtaTransactionErrorHandler, jtaTransactionErrorHandler, jtaTransactionErrorHandler, method, method, method, method, noErrorHandler, regexReplaceAll, regexReplaceAll, setCamelContext, simple, simple, simpleF, simpleF, springTransactionErrorHandler, springTransactionErrorHandler, springTransactionErrorHandler, systemProperty, systemProperty, variable, xpath, xpath, xpath, xpath

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.apache.activemq.artemis.core.server.plugin.ActiveMQServerBasePlugin

    init, registered, setInit, unregistered

    Methods inherited from interface org.apache.activemq.artemis.core.server.plugin.ActiveMQServerSessionPlugin

    afterCloseSession, afterSessionMetadataAdded, beforeCloseSession, beforeCreateSession, beforeSessionMetadataAdded, duplicateSessionMetadataFailure
  • Field Details

    • MQTT_FORCE_USER_DISCONNECT_DEBOUNCE_MILLIS

      public static final String MQTT_FORCE_USER_DISCONNECT_DEBOUNCE_MILLIS
      See Also:
    • MQTT_FORCE_USER_DISCONNECT_DEBOUNCE_MILLIS_DEFAULT

      public static int MQTT_FORCE_USER_DISCONNECT_DEBOUNCE_MILLIS_DEFAULT
    • PRIORITY

      public static final int PRIORITY
      See Also:
    • MQTT_SERVER_LISTEN_HOST

      public static final String MQTT_SERVER_LISTEN_HOST
      See Also:
    • MQTT_SERVER_LISTEN_PORT

      public static final String MQTT_SERVER_LISTEN_PORT
      See Also:
    • ANONYMOUS_USERNAME

      public static final String ANONYMOUS_USERNAME
      See Also:
    • wildcardConfiguration

      protected final org.apache.activemq.artemis.core.config.WildcardConfiguration wildcardConfiguration
    • LOG

      protected static final System.Logger LOG
    • assetStorageService

      protected AssetStorageService assetStorageService
    • authorisationService

      protected AuthorisationService authorisationService
    • identityProvider

      protected ManagerKeycloakIdentityProvider identityProvider
    • clientEventService

      protected ClientEventService clientEventService
    • messageBrokerService

      protected org.openremote.container.message.MessageBrokerService messageBrokerService
    • executorService

      protected ExecutorService executorService
    • timerService

      protected org.openremote.container.timer.TimerService timerService
    • assetProcessingService

      protected AssetProcessingService assetProcessingService
    • customHandlers

      protected List<MQTTHandler> customHandlers
    • clientIDConnectionMap

      protected ConcurrentMap<String,org.apache.activemq.artemis.spi.core.protocol.RemotingConnection> clientIDConnectionMap
    • connectionIDConnectionMap

      protected ConcurrentMap<String,org.apache.activemq.artemis.spi.core.protocol.RemotingConnection> connectionIDConnectionMap
    • userAssetLinkChangeMap

      protected ConcurrentMap<String,List<org.openremote.model.PersistenceEvent<org.openremote.model.asset.UserAssetLink>>> userAssetLinkChangeMap
    • userAssetDisconnectDebouncer

      protected org.openremote.model.util.Debouncer<String> userAssetDisconnectDebouncer
    • disconnectedConnectionCache

      protected com.google.common.cache.Cache<String,org.apache.activemq.artemis.spi.core.protocol.RemotingConnection> disconnectedConnectionCache
    • active

      protected boolean active
    • host

      protected String host
    • port

      protected int port
    • serverConfiguration

      protected org.apache.activemq.artemis.core.config.Configuration serverConfiguration
    • server

      protected org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ server
    • securityManager

      protected ActiveMQORSecurityManager securityManager
    • serverLocator

      protected org.apache.activemq.artemis.api.core.client.ServerLocator serverLocator
    • sessionFactory

      protected org.apache.activemq.artemis.api.core.client.ClientSessionFactory sessionFactory
  • Constructor Details

    • MQTTBrokerService

      public MQTTBrokerService()
  • Method Details

    • getPriority

      public int getPriority()
      Specified by:
      getPriority in interface org.openremote.model.ContainerService
    • init

      public void init(org.openremote.model.Container container) throws Exception
      Specified by:
      init in interface org.openremote.model.ContainerService
      Throws:
      Exception
    • start

      public void start(org.openremote.model.Container container) throws Exception
      Specified by:
      start in interface org.openremote.model.ContainerService
      Throws:
      Exception
    • configure

      public void configure() throws Exception
      Specified by:
      configure in class org.apache.camel.builder.RouteBuilder
      Throws:
      Exception
    • stop

      public void stop(org.openremote.model.Container container) throws Exception
      Specified by:
      stop in interface org.openremote.model.ContainerService
      Throws:
      Exception
    • afterCreateConnection

      public void afterCreateConnection(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection connection) throws org.apache.activemq.artemis.api.core.ActiveMQException
      Specified by:
      afterCreateConnection in interface org.apache.activemq.artemis.core.server.plugin.ActiveMQServerConnectionPlugin
      Throws:
      org.apache.activemq.artemis.api.core.ActiveMQException
    • afterCreateSession

      public void afterCreateSession(org.apache.activemq.artemis.core.server.ServerSession session) throws org.apache.activemq.artemis.api.core.ActiveMQException
      Specified by:
      afterCreateSession in interface org.apache.activemq.artemis.core.server.plugin.ActiveMQServerSessionPlugin
      Throws:
      org.apache.activemq.artemis.api.core.ActiveMQException
    • afterDestroyConnection

      public void afterDestroyConnection(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection connection) throws org.apache.activemq.artemis.api.core.ActiveMQException
      Specified by:
      afterDestroyConnection in interface org.apache.activemq.artemis.core.server.plugin.ActiveMQServerConnectionPlugin
      Throws:
      org.apache.activemq.artemis.api.core.ActiveMQException
    • onSubscribe

      public void onSubscribe(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection connection, String topicStr)
    • onUnsubscribe

      public void onUnsubscribe(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection connection, String topicStr)
    • getCustomHandlers

      public Iterable<MQTTHandler> getCustomHandlers()
    • processUserAssetLinkChange

      public void processUserAssetLinkChange(String userID, List<org.openremote.model.PersistenceEvent<org.openremote.model.asset.UserAssetLink>> changes)
    • getUserConnections

      public Set<org.apache.activemq.artemis.spi.core.protocol.RemotingConnection> getUserConnections(String userID)
      Get active connections for the specified user ID
    • doForceDisconnect

      protected void doForceDisconnect(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection connection)
    • disconnectSession

      public boolean disconnectSession(String connectionID)
    • getWildcardConfiguration

      public org.apache.activemq.artemis.core.config.WildcardConfiguration getWildcardConfiguration()
    • getConnectionIDString

      public static String getConnectionIDString(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection connection)
    • connectionToString

      public static String connectionToString(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection connection)
    • getSubjectName

      public static String getSubjectName(Subject subject)
    • getConnectionFromClientID

      public org.apache.activemq.artemis.spi.core.protocol.RemotingConnection getConnectionFromClientID(String clientID)
    • notifyConnectionAuthenticated

      protected void notifyConnectionAuthenticated(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection connection)
    • createSession

      protected org.apache.activemq.artemis.api.core.client.ClientSession createSession() throws Exception
      Create a client session for communicating with the broker
      Throws:
      Exception
    • getServerWildcardConfiguration

      protected org.apache.activemq.artemis.core.config.WildcardConfiguration getServerWildcardConfiguration()
    • authenticateConnection

      public void authenticateConnection(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection connection, String realm, String username, String password)