Interface ActionMessageQueue

All Known Implementing Classes:
SimpleActionMessageQueue

public interface ActionMessageQueue
API for thread-safe management of action message queues partitioned by client identifiers.

The operations in this API are all thread-safe. Any method that gives access a Deque, like addPendingMessage(PendingActionMessage, Consumer) or allQueues() should synchronize on those instances for thread safety.

Version:
1.0
Author:
matt
  • Method Details

    • pendingMessageQueue

      Deque<PendingActionMessage> pendingMessageQueue(ChargePointIdentity clientId)
      Get the pending message queue for a specific client.
      Parameters:
      clientId - the client ID
      Returns:
      the queue, never null
    • addPendingMessage

      default void addPendingMessage(PendingActionMessage msg)
      Add a message to the pending message queue.

      The pending message's ActionMessage.getClientId() will determine the client queue the message is added to.

      Parameters:
      msg - the message to add
    • addPendingMessage

      void addPendingMessage(PendingActionMessage msg, Consumer<Deque<PendingActionMessage>> fn)
      Add a message to the pending message queue.

      The pending message's ActionMessage.getClientId() will determine the client queue the message is added to.

      Parameters:
      msg - the message to add
      fn - an optional function to apply synchronously
    • pollPendingMessage

      PendingActionMessage pollPendingMessage(ChargePointIdentity clientId)
      Find and remove the first available message from the pending message queue.
      Parameters:
      clientId - the ID of the client
      Returns:
      the found message, or null if no messages available
    • pollPendingMessage

      PendingActionMessage pollPendingMessage(ChargePointIdentity clientId, String messageId)
      Find and remove a message from the pending message queue, based on its message ID.

      This method will search the pending messages queue and return the first message found with the matching message ID, after first removing that message from the queue.

      Parameters:
      clientId - the ID of the client
      messageId - the ID to find
      Returns:
      the found message, or null if not found
    • allQueues

      Get an iterable for all available queues.
      Returns:
      the iterable, never null