Class MqttService
java.lang.Object
energy.eddie.regionconnector.aiida.mqtt.MqttService
- All Implemented Interfaces:
AutoCloseable
-
Constructor Summary
ConstructorsConstructorDescriptionMqttService(MqttUserRepository userRepository, MqttAclRepository aclRepository, PasswordGenerator passwordGenerator, org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder bCryptPasswordEncoder, org.eclipse.paho.mqttv5.client.MqttAsyncClient mqttClient, AiidaConfiguration aiidaConfiguration, MqttMessageCallback mqttMessageCallback) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()createCredentialsAndAclForPermission(String permissionId, boolean isInbound) Creates and saves a newMqttUserwith a random password for the specified permission and creates ACLs to allow the new user to publish data and status messages, as well as to subscribe to its termination topic.voiddeleteAclsForPermission(String permissionId) Deletes all associated ACLs for the specified permission ID.voidsendTerminationRequest(AiidaPermissionRequest permissionRequest) voidsubscribeToOutboundDataTopic(String permissionId) voidsubscribeToStatusTopic(String permissionId)
-
Constructor Details
-
Method Details
-
createCredentialsAndAclForPermission
public MqttDto createCredentialsAndAclForPermission(String permissionId, boolean isInbound) throws CredentialsAlreadyExistException Creates and saves a newMqttUserwith a random password for the specified permission and creates ACLs to allow the new user to publish data and status messages, as well as to subscribe to its termination topic. The newly created user and ACLs will be available to the MQTT broker, if it's configured to read from the database.Important: This method does not validate if there is a permission with the ID
permissionId.- Parameters:
permissionId- For which permission to create the user.- Returns:
- MqttDto that contains the topics and the
MqttUserwith its password. - Throws:
IllegalArgumentException- If there is already a MqttUser for the permissionId.CredentialsAlreadyExistException
-
deleteAclsForPermission
Deletes all associated ACLs for the specified permission ID.- Parameters:
permissionId- The permission ID for which to delete the credentials and ACLs.
-
close
public void close() throws org.eclipse.paho.mqttv5.common.MqttException- Specified by:
closein interfaceAutoCloseable- Throws:
org.eclipse.paho.mqttv5.common.MqttException
-
subscribeToOutboundDataTopic
public void subscribeToOutboundDataTopic(String permissionId) throws org.eclipse.paho.mqttv5.common.MqttException - Throws:
org.eclipse.paho.mqttv5.common.MqttException
-
subscribeToStatusTopic
public void subscribeToStatusTopic(String permissionId) throws org.eclipse.paho.mqttv5.common.MqttException - Throws:
org.eclipse.paho.mqttv5.common.MqttException
-
sendTerminationRequest
public void sendTerminationRequest(AiidaPermissionRequest permissionRequest) throws org.eclipse.paho.mqttv5.common.MqttException - Throws:
org.eclipse.paho.mqttv5.common.MqttException
-