Interface MessageQueue

  • All Known Implementing Classes:
    MessageVector

    public interface MessageQueue
    Interface MessageQueue represents a First-In-First-Out (FIFO) persistent list of Message (source and target agent identifier, notification).
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      Message get()
      Looks at the message at the top of this queue without removing it from the queue.
      Message get​(long timeout)
      Looks at the message at the top of this queue without removing it from the queue.
      void insert​(Message item, MessageComparator comparator)
      Insert a message in the queue, it should only be used during initialization for restoring the queue state.
      Message pop()
      Removes the message at the top of this queue.
      void push​(Message item)
      Pushes a message onto the bottom of this queue.
      void pushAndValidate​(Message item)
      Pushes a message and validates it at the same time.
      String report()
      Returns a report about the distribution of messages type in queue.
      int size()
      Returns the number of messages in this MessageQueue object.
      void validate()
      Atomically validates all messages pushed in queue during a reaction.
    • Method Detail

      • insert

        void insert​(Message item,
                    MessageComparator comparator)
        Insert a message in the queue, it should only be used during initialization for restoring the queue state. This algorithm sould take into account the reinitialization of the stamp and makes it possible to suitably sort messages having been created before this reset.
        Parameters:
        item - the message to be pushed onto this queue.
        comparator - the MessageComparator interface of MessageConsumer.
      • push

        void push​(Message item)
        Pushes a message onto the bottom of this queue. It should only be used during a transaction. The item will be really available after the transaction commit and the queue validate.
        Parameters:
        item - the message to be pushed onto this queue.
      • pushAndValidate

        void pushAndValidate​(Message item)
        Pushes a message and validates it at the same time.
        Parameters:
        item - the message to be pushed and validated
      • pop

        Message pop()
             throws EmptyQueueException
        Removes the message at the top of this queue. It must only be used during a transaction.
        Returns:
        The message at the top of this queue.
        Throws:
        EmptyQueueException - if this queue is empty.
      • validate

        void validate()
        Atomically validates all messages pushed in queue during a reaction. It must only be used during a transaction.
      • get

        Message get()
             throws InterruptedException
        Looks at the message at the top of this queue without removing it from the queue. It should never be used during a transaction to avoid dead-lock problems.
        Returns:
        the message at the top of this queue.
        Throws:
        InterruptedException - if another thread has interrupted the current thread.
      • get

        Message get​(long timeout)
             throws InterruptedException
        Looks at the message at the top of this queue without removing it from the queue. It waits until a message is available or the specified amount of time has elapsed. It should never be used during a transaction to avoid dead-lock problems.
        Parameters:
        timeout - the maximum time to wait in milliseconds.
        Returns:
        the message at the top of this queue.
        Throws:
        InterruptedException - if another thread has interrupted the current thread.
        IllegalArgumentException - if the value of timeout is negative.
      • size

        int size()
        Returns the number of messages in this MessageQueue object. Be careful, the result includes messages to be validated.
        Returns:
        the size of the MessageQueue
      • report

        String report()
        Returns a report about the distribution of messages type in queue.
        Returns:
        a report about the distribution of messages type in queue.