Class MqttStreamer

java.lang.Object
energy.eddie.aiida.streamers.AiidaStreamer
energy.eddie.aiida.streamers.mqtt.MqttStreamer
All Implemented Interfaces:
AutoCloseable, org.eclipse.paho.mqttv5.client.MqttCallback

public class MqttStreamer extends AiidaStreamer implements org.eclipse.paho.mqttv5.client.MqttCallback
  • Constructor Details

    • MqttStreamer

      public MqttStreamer(UUID aiidaId, FailedToSendRepository failedToSendRepository, com.fasterxml.jackson.databind.ObjectMapper mapper, Permission permission, reactor.core.publisher.Flux<AiidaRecord> recordFlux, MqttStreamingContext streamingContext, reactor.core.publisher.Sinks.One<UUID> terminationRequestSink)
      Creates a new MqttStreamer and initialized the client callback.
      Parameters:
      aiidaId - UUID of the AIIDA instance for which to create the AiidaStreamer.
      failedToSendRepository - Repository where messages that could not be transmitted are stored.
      mapper - ObjectMapper used to transform the values to be sent into JSON strings.
      permission - Permission for which this streamer is created.
      recordFlux - Flux, where records that should be sent are published.
      streamingContext - Holds the MqttAsyncClient used to send to MQTT broker and the necessary MQTT configuration values.
      terminationRequestSink - Sink, to which the ID of the permission will be published when the EP requests a termination.
  • Method Details

    • connect

      public void connect()
      Description copied from class: AiidaStreamer
      Open required connections to the streaming target (EP) in this method, not beforehand. Subscribe to the Fluxes in this method, to receive records and status messages that shall be sent. Start listening for termination requests from the EP.
      Specified by:
      connect in class AiidaStreamer
    • close

      public void close()
      Description copied from class: AiidaStreamer
      Unsubscribe from any Flux and free any used resources in this method. May flush all queued messages beforehand.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in class AiidaStreamer
    • closeTerminally

      public void closeTerminally(AiidaConnectionStatusMessageDto statusMessage)
      Description copied from class: AiidaStreamer
      Sends a AiidaConnectionStatusMessageDto with the passed status before closing this streamer for good. May block until the passed statusMessage is transmitted.
      Specified by:
      closeTerminally in class AiidaStreamer
      See Also:
    • 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
    • messageArrived

      public void messageArrived(String topic, org.eclipse.paho.mqttv5.common.MqttMessage message)
      Specified by:
      messageArrived in interface org.eclipse.paho.mqttv5.client.MqttCallback
    • deliveryComplete

      public void deliveryComplete(org.eclipse.paho.mqttv5.client.IMqttToken token)
      Specified by:
      deliveryComplete in interface org.eclipse.paho.mqttv5.client.MqttCallback
    • connectComplete

      public void connectComplete(boolean reconnect, String serverURI)
      Specified by:
      connectComplete in interface org.eclipse.paho.mqttv5.client.MqttCallback
    • 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