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
commandSink, recordFlux, schemaFormatterRegistry -
Constructor Summary
ConstructorsConstructorDescriptionMqttStreamer(FailedToSendRepository failedToSendRepository, tools.jackson.databind.ObjectMapper mapper, Permission permission, reactor.core.publisher.Flux<AiidaRecord> recordFlux, SchemaFormatterRegistry schemaFormatterRegistry, MqttStreamingContext streamingContext, reactor.core.publisher.Sinks.Many<PermissionCommand> commandSink) 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) voidsetTransmissionEnabled(boolean enabled) Enables or disables data transmission for this streamer.voidupdateRecordFlux(reactor.core.publisher.Flux<AiidaRecord> recordFlux) Replaces the record flux this streamer is subscribed to and resubscribes.
-
Constructor Details
-
MqttStreamer
public MqttStreamer(FailedToSendRepository failedToSendRepository, tools.jackson.databind.ObjectMapper mapper, Permission permission, reactor.core.publisher.Flux<AiidaRecord> recordFlux, SchemaFormatterRegistry schemaFormatterRegistry, MqttStreamingContext streamingContext, reactor.core.publisher.Sinks.Many<PermissionCommand> commandSink) Creates a new MqttStreamer and initialized the client callback.- Parameters:
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.schemaFormatterRegistry- Registry of all available schema formattersstreamingContext- Holds theMqttAsyncClientused to send to MQTT broker and the necessary MQTT configuration values.commandSink- Sink, to which aPermissionCommandis published when the EP sends a control command.
-
-
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
-
setTransmissionEnabled
public void setTransmissionEnabled(boolean enabled) Description copied from class:AiidaStreamerEnables or disables data transmission for this streamer. While disabled, records are not published to the EP.- Specified by:
setTransmissionEnabledin classAiidaStreamer
-
updateRecordFlux
Description copied from class:AiidaStreamerReplaces the record flux this streamer is subscribed to and resubscribes. Used to apply a new transmission schedule, which re-aggregates the upstream records on a different cadence.- Specified by:
updateRecordFluxin classAiidaStreamer
-
authPacketArrived
public void authPacketArrived(int reasonCode, org.eclipse.paho.mqttv5.common.packet.MqttProperties properties) - Specified by:
authPacketArrivedin interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-