fr.dyade.aaa.agent
Interface MessageQueue

All Known Implementing Classes:
MessageVector

interface MessageQueue

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


Method Summary
 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)
          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.
 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)
Insert a message in the queue, it should only be used during initialization for restoring the queue state.

Parameters:
item - the message to be pushed onto this queue.

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.

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 java.lang.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:
java.lang.InterruptedException - if another thread has interrupted the current thread.

get

Message get(long timeout)
            throws java.lang.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:
java.lang.InterruptedException - if another thread has interrupted the current thread.
java.lang.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


Copyright © 2010 ScalAgent D.T.. All Rights Reserved.