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.health.contributor.HealthContributor, org.springframework.boot.health.contributor.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 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.health.contributor.Health health()
      Specified by:
      health in interface org.springframework.boot.health.contributor.HealthIndicator
      Overrides:
      health in class DataSourceAdapter<T extends MqttDataSource>
    • setKeepAliveInterval

      public void setKeepAliveInterval(Integer keepAliveInterval)
    • subscribeToHealthTopic

      protected void subscribeToHealthTopic()
    • createConnectOptions

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