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
-
Field Summary
Fields inherited from class energy.eddie.aiida.streamers.AiidaStreamer
aiidaId, recordFlux, terminationRequestSink -
Constructor Summary
ConstructorsConstructorDescriptionMqttStreamer(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. -
Method Summary
Modifier and TypeMethodDescriptionvoidauthPacketArrived(int reasonCode, org.eclipse.paho.mqttv5.common.packet.MqttProperties properties) voidclose()Unsubscribe from any Flux and free any used resources in this method.voidcloseTerminally(AiidaConnectionStatusMessageDto statusMessage) Sends aAiidaConnectionStatusMessageDtowith the passedstatusbefore closing this streamer for good.voidconnect()Open required connections to the streaming target (EP) in this method, not beforehand.voidconnectComplete(boolean reconnect, String serverURI) voiddeliveryComplete(org.eclipse.paho.mqttv5.client.IMqttToken token) voiddisconnected(org.eclipse.paho.mqttv5.client.MqttDisconnectResponse disconnectResponse) voidmessageArrived(String topic, org.eclipse.paho.mqttv5.common.MqttMessage message) voidmqttErrorOccurred(org.eclipse.paho.mqttv5.common.MqttException exception)
-
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-ObjectMapperused 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 theMqttAsyncClientused 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:AiidaStreamerOpen 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:
connectin classAiidaStreamer
-
close
public void close()Description copied from class:AiidaStreamerUnsubscribe from any Flux and free any used resources in this method. May flush all queued messages beforehand.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein classAiidaStreamer
-
closeTerminally
Description copied from class:AiidaStreamerSends aAiidaConnectionStatusMessageDtowith the passedstatusbefore closing this streamer for good. May block until the passedstatusMessageis transmitted.- Specified by:
closeTerminallyin classAiidaStreamer- See Also:
-
disconnected
public void disconnected(org.eclipse.paho.mqttv5.client.MqttDisconnectResponse disconnectResponse) - Specified by:
disconnectedin interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-
mqttErrorOccurred
public void mqttErrorOccurred(org.eclipse.paho.mqttv5.common.MqttException exception) - Specified by:
mqttErrorOccurredin interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-
messageArrived
- Specified by:
messageArrivedin interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-
deliveryComplete
public void deliveryComplete(org.eclipse.paho.mqttv5.client.IMqttToken token) - Specified by:
deliveryCompletein interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-
connectComplete
- Specified by:
connectCompletein interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-
authPacketArrived
public void authPacketArrived(int reasonCode, org.eclipse.paho.mqttv5.common.packet.MqttProperties properties) - Specified by:
authPacketArrivedin interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-