Class MqttStreamer
java.lang.Object
energy.eddie.aiida.streamers.mqtt.MqttStreamer
- All Implemented Interfaces:
AiidaStreamer,AutoCloseable,org.eclipse.paho.mqttv5.client.MqttCallback
public class MqttStreamer
extends Object
implements AiidaStreamer, org.eclipse.paho.mqttv5.client.MqttCallback
-
Constructor Summary
ConstructorsConstructorDescriptionMqttStreamer(StreamerDependencies dependencies, AcceptedPermission permission, reactor.core.publisher.Flux<AiidaRecord> recordFlux, MqttStreamingContext streamingContext) 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) booleanReturns whether this streamer is currently connected to the streaming target (EP).voidmessageArrived(String topic, org.eclipse.paho.mqttv5.common.MqttMessage message) voidmqttErrorOccurred(org.eclipse.paho.mqttv5.common.MqttException exception) voidpublishSchemaPayload(UUID permissionId, AiidaSchema schema, String payload) Publishes a payload of the provided schema to the permission of the provided id.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(StreamerDependencies dependencies, AcceptedPermission permission, reactor.core.publisher.Flux<AiidaRecord> recordFlux, MqttStreamingContext streamingContext) Creates a new MqttStreamer and initialized the client callback.- Parameters:
dependencies- Streamer dependencies shared by every streamer implementation.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.
-
-
Method Details
-
connect
public void connect()Description copied from interface: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 interfaceAiidaStreamer
-
isConnected
public boolean isConnected()Description copied from interface:AiidaStreamerReturns whether this streamer is currently connected to the streaming target (EP).- Specified by:
isConnectedin interfaceAiidaStreamer
-
close
public void close()Description copied from interface:AiidaStreamerUnsubscribe from any Flux and free any used resources in this method. May flush all queued messages beforehand.- Specified by:
closein interfaceAiidaStreamer- Specified by:
closein interfaceAutoCloseable
-
closeTerminally
Description copied from interface:AiidaStreamerSends aAiidaConnectionStatusMessageDtowith the passedstatusbefore closing this streamer for good. May block until the passedstatusMessageis transmitted.- Specified by:
closeTerminallyin interfaceAiidaStreamer- 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 interface:AiidaStreamerEnables or disables data transmission for this streamer. While disabled, records are not published to the EP.- Specified by:
setTransmissionEnabledin interfaceAiidaStreamer
-
updateRecordFlux
Description copied from interface: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 interfaceAiidaStreamer
-
publishSchemaPayload
Description copied from interface:AiidaStreamerPublishes a payload of the provided schema to the permission of the provided id.- Specified by:
publishSchemaPayloadin interfaceAiidaStreamer
-
authPacketArrived
public void authPacketArrived(int reasonCode, org.eclipse.paho.mqttv5.common.packet.MqttProperties properties) - Specified by:
authPacketArrivedin interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-