Class MqttDataSourceAdapter<T extends MqttDataSource>

java.lang.Object
energy.eddie.aiida.adapters.datasource.DataSourceAdapter<T>
energy.eddie.aiida.adapters.datasource.MqttDataSourceAdapter<T>
All Implemented Interfaces:
AutoCloseable, org.eclipse.paho.mqttv5.client.MqttCallback, org.springframework.boot.actuate.health.HealthContributor, org.springframework.boot.actuate.health.HealthIndicator
Direct Known Subclasses:
CimAdapter, InboundAdapter, MicroTeleinfoV3Adapter, OesterreichsEnergieAdapter, ShellyAdapter, SinapsiAlfaAdapter, SmartGatewaysAdapter

public abstract class MqttDataSourceAdapter<T extends MqttDataSource> extends DataSourceAdapter<T> implements org.eclipse.paho.mqttv5.client.MqttCallback
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.eclipse.paho.mqttv5.client.MqttAsyncClient
     

    Fields inherited from class energy.eddie.aiida.adapters.datasource.DataSourceAdapter

    dataSource, healthSink, recordSink
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    MqttDataSourceAdapter(T dataSource, org.slf4j.Logger childLogger, MqttConfiguration mqttConfiguration)
    Creates a new MqttDataSourceAdapter with the specified display name and mqttConfig.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    authPacketArrived(int reasonCode, org.eclipse.paho.mqttv5.common.packet.MqttProperties properties)
     
    void
    Close any open connections and free resources used by this class.
    void
    connectComplete(boolean reconnect, String serverURI)
    Called when the connection to the broker has been established and will then subscribe to the topic specified in mqttConfig.
    protected org.eclipse.paho.mqttv5.client.MqttConnectionOptions
     
    void
    deliveryComplete(org.eclipse.paho.mqttv5.client.IMqttToken token)
    Will always throw UnsupportedOperationException, as this datasource is not designed to publish data.
    void
    disconnected(org.eclipse.paho.mqttv5.client.MqttDisconnectResponse disconnectResponse)
     
    org.springframework.boot.actuate.health.Health
     
    void
    mqttErrorOccurred(org.eclipse.paho.mqttv5.common.MqttException exception)
     
    void
    setKeepAliveInterval(Integer keepAliveInterval)
     
    reactor.core.publisher.Flux<AiidaRecord>
    Start the listening or active polling for data from the datasource.
    protected void
     

    Methods inherited from class energy.eddie.aiida.adapters.datasource.DataSourceAdapter

    create, dataSource, emitAiidaRecord

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface org.springframework.boot.actuate.health.HealthIndicator

    getHealth

    Methods inherited from interface org.eclipse.paho.mqttv5.client.MqttCallback

    messageArrived
  • Field Details

    • asyncClient

      @Nullable protected org.eclipse.paho.mqttv5.client.MqttAsyncClient asyncClient
  • Constructor Details

    • MqttDataSourceAdapter

      protected MqttDataSourceAdapter(T dataSource, org.slf4j.Logger childLogger, MqttConfiguration mqttConfiguration)
      Creates a new MqttDataSourceAdapter with the specified display name and mqttConfig.
      Parameters:
      dataSource - The entity of the data source.
  • Method Details

    • start

      public reactor.core.publisher.Flux<AiidaRecord> start()
      Start the listening or active polling for data from the datasource. The time field from the adapter is interpreted as unix timestamp.
      Specified by:
      start in class DataSourceAdapter<T extends MqttDataSource>
      Returns:
      Flux on which all data from this datasource will be published.
    • close

      public void close()
      Close any open connections and free resources used by this class. Also emit a complete signal on the recordSink of this datasource.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in class DataSourceAdapter<T extends MqttDataSource>
    • disconnected

      public void disconnected(org.eclipse.paho.mqttv5.client.MqttDisconnectResponse disconnectResponse)
      Specified by:
      disconnected in interface org.eclipse.paho.mqttv5.client.MqttCallback
    • mqttErrorOccurred

      public void mqttErrorOccurred(org.eclipse.paho.mqttv5.common.MqttException exception)
      Specified by:
      mqttErrorOccurred in interface org.eclipse.paho.mqttv5.client.MqttCallback
    • deliveryComplete

      public void deliveryComplete(org.eclipse.paho.mqttv5.client.IMqttToken token)
      Will always throw UnsupportedOperationException, as this datasource is not designed to publish data.
      Specified by:
      deliveryComplete in interface org.eclipse.paho.mqttv5.client.MqttCallback
      Parameters:
      token - The delivery token associated with the message.
      Throws:
      UnsupportedOperationException - Always thrown, as this datasource is not designed to publish data.
    • connectComplete

      public void connectComplete(boolean reconnect, String serverURI)
      Called when the connection to the broker has been established and will then subscribe to the topic specified in mqttConfig.
      Specified by:
      connectComplete in interface org.eclipse.paho.mqttv5.client.MqttCallback
      Parameters:
      reconnect - If true, the connection was the result of automatic reconnect.
      serverURI - The server URI that the connection was made to.
    • authPacketArrived

      public void authPacketArrived(int reasonCode, org.eclipse.paho.mqttv5.common.packet.MqttProperties properties)
      Specified by:
      authPacketArrived in interface org.eclipse.paho.mqttv5.client.MqttCallback
    • health

      public org.springframework.boot.actuate.health.Health health()
      Specified by:
      health in interface org.springframework.boot.actuate.health.HealthIndicator
    • setKeepAliveInterval

      public void setKeepAliveInterval(Integer keepAliveInterval)
    • subscribeToHealthTopic

      protected void subscribeToHealthTopic()
    • createConnectOptions

      protected org.eclipse.paho.mqttv5.client.MqttConnectionOptions createConnectOptions()