Class MqttService

java.lang.Object
energy.eddie.regionconnector.aiida.mqtt.MqttService
All Implemented Interfaces:
AutoCloseable

@Service public class MqttService extends Object implements AutoCloseable
  • Constructor Details

  • Method Details

    • createCredentialsAndAclForPermission

      public MqttDto createCredentialsAndAclForPermission(String permissionId, boolean isInbound) throws CredentialsAlreadyExistException
      Creates and saves a new MqttUser with 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 MqttUser with its password.
      Throws:
      IllegalArgumentException - If there is already a MqttUser for the permissionId.
      CredentialsAlreadyExistException
    • deleteAclsForPermission

      public void deleteAclsForPermission(String permissionId)
      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:
      close in interface AutoCloseable
      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