Package energy.eddie.aiida.provisioning
Class ProvisioningMqttPublisher
java.lang.Object
energy.eddie.aiida.provisioning.ProvisioningMqttPublisher
- All Implemented Interfaces:
AutoCloseable,org.eclipse.paho.mqttv5.client.MqttCallback
public class ProvisioningMqttPublisher
extends Object
implements org.eclipse.paho.mqttv5.client.MqttCallback, AutoCloseable
-
Constructor Summary
ConstructorsConstructorDescriptionProvisioningMqttPublisher(MqttConnection mqttConnection, String topic) Creates a publisher and starts an asynchronous connection to the configured MQTT broker.ProvisioningMqttPublisher(MqttConnection mqttConnection, String topic, String connectionUsername, String connectionPassword) Creates a publisher with connection credentials that are independent of the persisted provisioning user. -
Method Summary
Modifier and TypeMethodDescriptionvoidauthPacketArrived(int reasonCode, org.eclipse.paho.mqttv5.common.packet.MqttProperties properties) voidclose()Disconnects and closes the MQTT client.voidconnectComplete(boolean reconnect, String serverURI) voiddeliveryComplete(org.eclipse.paho.mqttv5.client.IMqttToken token) voiddisconnected(org.eclipse.paho.mqttv5.client.MqttDisconnectResponse disconnectResponse) booleanIndicates whether the publisher currently has an established MQTT connection.voidmessageArrived(String topic, org.eclipse.paho.mqttv5.common.MqttMessage message) voidmqttErrorOccurred(org.eclipse.paho.mqttv5.common.MqttException exception) voidpublish(InboundRecord inboundRecord) Publishes the payload of an inbound record when the MQTT client is connected.
-
Constructor Details
-
ProvisioningMqttPublisher
Creates a publisher and starts an asynchronous connection to the configured MQTT broker.- Parameters:
mqttConnection- MQTT connection and credentials used by the publisher.topic- Topic to which inbound records are published.
-
ProvisioningMqttPublisher
public ProvisioningMqttPublisher(MqttConnection mqttConnection, String topic, String connectionUsername, String connectionPassword) Creates a publisher with connection credentials that are independent of the persisted provisioning user. Server mode uses this overload so AIIDA connects with its stable broker identity while the generated per-permission user remains dedicated to the provisioning client.- Parameters:
mqttConnection- MQTT connection and persisted username.topic- Topic to which inbound records are published.connectionUsername- Username used to authenticate this publisher.connectionPassword- Plaintext password used to authenticate this publisher.
-
-
Method Details
-
publish
Publishes the payload of an inbound record when the MQTT client is connected. If the client is disconnected or publishing fails, the record is not sent and the method returns without propagating an MQTT exception.- Parameters:
inboundRecord- Record whose payload should be published.
-
close
public void close()Disconnects and closes the MQTT client. MQTT errors encountered during shutdown are logged and not propagated.- Specified by:
closein interfaceAutoCloseable
-
isConnected
public boolean isConnected()Indicates whether the publisher currently has an established MQTT connection.- Returns:
truewhen an MQTT client exists and is connected; otherwisefalse.
-
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
public void messageArrived(String topic, org.eclipse.paho.mqttv5.common.MqttMessage message) throws Exception - Specified by:
messageArrivedin interfaceorg.eclipse.paho.mqttv5.client.MqttCallback- Throws:
Exception
-
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
-