Class PollManager

java.lang.Object
io.levysworks.beans.PollManager

@ApplicationScoped public class PollManager extends Object
Bean used for sending add and remove key messages to the agent servers
  • Constructor Details

    • PollManager

      public PollManager()
  • Method Details

    • init

      @PostConstruct public void init()
      Initializes the RabbitMQ connection and declares necessary messaging infrastructure.

      Connects to the configured RabbitMQ server, declares the pollexchange topic exchange, and creates .add and .remove queues for each agent defined in AgentsConfig. This method is called automatically after bean construction.

    • addKeyForAgent

      public void addKeyForAgent(String agentName, String key) throws IOException, TimeoutException
      Publishes a new key to the specified agent's .add queue on the pollexchange exchange.
      Parameters:
      agentName - the target agent's name
      key - the key to be added
      Throws:
      IOException - if a RabbitMQ I/O error occurs
      TimeoutException - if the operation times out
    • removeKeyFromAgent

      public void removeKeyFromAgent(String agentName, String uid) throws IOException, TimeoutException
      Publishes a key removal request to the specified agent's .remove queue on the pollexchange exchange.
      Parameters:
      agentName - the target agent's name
      uid - the UID of the key to be removed
      Throws:
      IOException - if a RabbitMQ I/O error occurs
      TimeoutException - if the operation times out
    • checkAgentExists

      public boolean checkAgentExists(String agentName)
      Checks whether an agent exists in the AgentsConfig
      Parameters:
      agentName - The agent to look for
      Returns:
      true if the agent exists, false otherwise