Class MessageManager

java.lang.Object
com.codeheadsystems.queue.manager.MessageManager

@Singleton public class MessageManager extends Object
The Message manager. This links the DAO with the model. Right now they are tightly coupled, but by only having the DAO used here, we enforce that should it need to change we can.
  • Constructor Details

    • MessageManager

      @Inject public MessageManager(MessageDao dao, MessageFactory messageFactory, com.codeheadsystems.metrics.Metrics metrics)
      Instantiates a new Message manager.
      Parameters:
      dao - the dao
      messageFactory - the message factory
      metrics - the metrics
  • Method Details

    • saveMessage

      public Optional<Message> saveMessage(String messageType, String payload)
      Save message optional.
      Parameters:
      messageType - the message type
      payload - the payload
      Returns:
      the optional
    • setProcessing

      public void setProcessing(Message message)
      Sets processing.
      Parameters:
      message - the message
    • setActivating

      public void setActivating(Message message)
      Sets activating.
      Parameters:
      message - the message
    • setAllToPending

      public void setAllToPending()
      Sets all to pending.
    • getPendingMessages

      public List<Message> getPendingMessages(int limit)
      Gets pending messages, up to the limit. Oldest first.
      Parameters:
      limit - count of messages to get.
      Returns:
      the list.
    • counts

      public Map<State,Long> counts()
      Returns counts of all states.
      Returns:
      the map
    • getState

      public Optional<State> getState(Message message)
      Gets state.
      Parameters:
      message - the message
      Returns:
      the state
    • clearAll

      public void clearAll()
      Clear all.
    • clear

      public void clear(Message message)
      Clear.
      Parameters:
      message - the message