Class InMemoryConversationInbox

java.lang.Object
at.aimon.session.web.spi.inmemory.InMemoryConversationInbox
All Implemented Interfaces:
ConversationInbox

public final class InMemoryConversationInbox extends Object implements ConversationInbox
Single-process ConversationInbox backed by per-conversation lock-protected lists.

Implementation goal is correctness over throughput: each deliver/collect acquires the conversation's monitor so priority-then-FIFO ordering and atomic batch removal are trivially preserved. Sequence numbers issued from a single AtomicLong provide stable FIFO ordering across deliveries.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    collect(at.aimon.core.agent.conversation.ConversationId id, at.aimon.core.agent.queue.QueuedInputPriority maxPriority)
    Atomically removes and returns up to all messages with priority ≤ maxPriority for id, in priority-then-FIFO order.
    Append message to its conversation's inbox.
    boolean
    isEmpty(at.aimon.core.agent.conversation.ConversationId id)
    Quick check without dequeuing.
    void
    purge(at.aimon.core.agent.conversation.ConversationId id)
    Drop every pending message for id (called from releaseConversation).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • InMemoryConversationInbox

      public InMemoryConversationInbox()
  • Method Details

    • deliver

      public InboundMessageId deliver(InboundMessage message)
      Description copied from interface: ConversationInbox
      Append message to its conversation's inbox.
      Specified by:
      deliver in interface ConversationInbox
      Parameters:
      message - the envelope (must not be null). The implementation typically assigns the InboundMessageId — the message.id field on entry is unused; the returned id is authoritative.
      Returns:
      the stable id assigned by this implementation
    • collect

      public List<InboundMessage> collect(at.aimon.core.agent.conversation.ConversationId id, at.aimon.core.agent.queue.QueuedInputPriority maxPriority)
      Description copied from interface: ConversationInbox
      Atomically removes and returns up to all messages with priority ≤ maxPriority for id, in priority-then-FIFO order.
      Specified by:
      collect in interface ConversationInbox
      Parameters:
      id - the conversation (must not be null)
      maxPriority - inclusive ceiling — NOW returns only NOW, LATER returns all tiers
      Returns:
      collected messages (never null; may be empty)
    • isEmpty

      public boolean isEmpty(at.aimon.core.agent.conversation.ConversationId id)
      Description copied from interface: ConversationInbox
      Quick check without dequeuing.
      Specified by:
      isEmpty in interface ConversationInbox
      Parameters:
      id - the conversation (must not be null)
      Returns:
      true when the inbox has zero pending messages for id
    • purge

      public void purge(at.aimon.core.agent.conversation.ConversationId id)
      Description copied from interface: ConversationInbox
      Drop every pending message for id (called from releaseConversation).
      Specified by:
      purge in interface ConversationInbox
      Parameters:
      id - the conversation (must not be null)