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.actuate.health.HealthContributor,org.springframework.boot.actuate.health.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 Summary
FieldsModifier and TypeFieldDescriptionprotected org.eclipse.paho.mqttv5.client.MqttAsyncClientFields inherited from class energy.eddie.aiida.adapters.datasource.DataSourceAdapter
dataSource, healthSink, recordSink -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMqttDataSourceAdapter(T dataSource, org.slf4j.Logger childLogger, MqttConfiguration mqttConfiguration) Creates a newMqttDataSourceAdapterwith the specified display name and mqttConfig. -
Method Summary
Modifier and TypeMethodDescriptionvoidauthPacketArrived(int reasonCode, org.eclipse.paho.mqttv5.common.packet.MqttProperties properties) voidclose()Close any open connections and free resources used by this class.voidconnectComplete(boolean reconnect, String serverURI) Called when the connection to the broker has been established and will then subscribe to the topic specified inmqttConfig.protected org.eclipse.paho.mqttv5.client.MqttConnectionOptionsvoiddeliveryComplete(org.eclipse.paho.mqttv5.client.IMqttToken token) Will always throwUnsupportedOperationException, as this datasource is not designed to publish data.voiddisconnected(org.eclipse.paho.mqttv5.client.MqttDisconnectResponse disconnectResponse) org.springframework.boot.actuate.health.Healthhealth()voidmqttErrorOccurred(org.eclipse.paho.mqttv5.common.MqttException exception) voidsetKeepAliveInterval(Integer keepAliveInterval) reactor.core.publisher.Flux<AiidaRecord> start()Start the listening or active polling for data from the datasource.protected voidMethods inherited from class energy.eddie.aiida.adapters.datasource.DataSourceAdapter
create, dataSource, emitAiidaRecordMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.boot.actuate.health.HealthIndicator
getHealthMethods inherited from interface org.eclipse.paho.mqttv5.client.MqttCallback
messageArrived
-
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 newMqttDataSourceAdapterwith the specified display name and mqttConfig.- Parameters:
dataSource- The entity of the data source.
-
-
Method Details
-
start
Start the listening or active polling for data from the datasource. Thetimefield from the adapter is interpreted as unix timestamp.- Specified by:
startin classDataSourceAdapter<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 therecordSinkof this datasource.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein classDataSourceAdapter<T extends MqttDataSource>
-
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
-
deliveryComplete
public void deliveryComplete(org.eclipse.paho.mqttv5.client.IMqttToken token) Will always throwUnsupportedOperationException, as this datasource is not designed to publish data.- Specified by:
deliveryCompletein interfaceorg.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
Called when the connection to the broker has been established and will then subscribe to the topic specified inmqttConfig.- Specified by:
connectCompletein interfaceorg.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:
authPacketArrivedin interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-
health
public org.springframework.boot.actuate.health.Health health()- Specified by:
healthin interfaceorg.springframework.boot.actuate.health.HealthIndicator
-
setKeepAliveInterval
-
subscribeToHealthTopic
protected void subscribeToHealthTopic() -
createConnectOptions
protected org.eclipse.paho.mqttv5.client.MqttConnectionOptions createConnectOptions()
-