org.garret.jipc
Interface JIPCQueue

All Superinterfaces:
JIPCPrimitive

public interface JIPCQueue
extends JIPCPrimitive

FIFO queue primitive. This primitive allows to pass data between consumer and producer. Elements are fetched by consumer in First-In-First-Out order. It is possible to pass objects of any type in the queue. The only requirement is that it should be serializable (implements java.io.Serializable interface).
If class of the object (or of it's components) placed in the queue by producer can not be located by consumer, then JIPCClassNotFoundException will be thrown at the consumer.
Length of message queue is unlimited.
If more than one consumer tries to get element from the queue, thie requests will be satisfied in FIFO order.

Semantic of methods inherited from JIPCPrimitive:

waitFor
Wait until queue becomes not empty. If queue contains some elements then method immediatly returns. This method doesn't change the state of the queue.
reset
Removes all elements from the queue


Field Summary
 
Fields inherited from interface org.garret.jipc.JIPCPrimitive
DEFAULT_RANK
 
Method Summary
 void broadcast(java.io.Serializable obj)
          Broadcast message to all sessions currently connected to the queue.
 java.io.Serializable get()
          Get element from the queue.
 java.io.Serializable get(long timeout)
          Get element from the queue with timeout.
 java.io.Serializable priorityGet(int rank)
          Get element from the queue.
 java.io.Serializable priorityGet(int rank, long timeout)
          Get element from the queue with timeout.
 void put(java.io.Serializable obj)
          Put element at the end of the queue.
 int size()
          Get number of elements in queue
 
Methods inherited from interface org.garret.jipc.JIPCPrimitive
alreadyExists, close, getName, priorityWait, priorityWait, reset, waitFor, waitFor
 

Method Detail

broadcast

public void broadcast(java.io.Serializable obj)
               throws JIPCException,
                      java.io.IOException
Broadcast message to all sessions currently connected to the queue. The message will no be deleted from the queue until all session read this

Parameters:
obj - any not-null serializable object
JIPCException
java.io.IOException

get

public java.io.Serializable get()
                         throws JIPCException,
                                java.io.IOException
Get element from the queue. If queue is empty this method waits until somebody else put element in the queue.
If class of the object (or of it's components) placed in the queue by producer can not be located at this system, then JIPCClassNotFoundException will be thrown.

Returns:
first element in queue
JIPCException
java.io.IOException

get

public java.io.Serializable get(long timeout)
                         throws JIPCException,
                                java.io.IOException
Get element from the queue with timeout.

Returns:
null if timeout is expired before any element was placed in the queue.
JIPCException
java.io.IOException

priorityGet

public java.io.Serializable priorityGet(int rank)
                                 throws JIPCException,
                                        java.io.IOException
Get element from the queue. If queue is empty this method waits until somebody else put element in the queue.
If class of the object (or of it's components) placed in the queue by producer can not be located at this system, then JIPCClassNotFoundException will be thrown.

Parameters:
rank - processes will be placed in wait queue in the order of increasing rank value and in the same order will be taken from the queue.
Returns:
first element in queue
JIPCException
java.io.IOException

priorityGet

public java.io.Serializable priorityGet(int rank,
                                        long timeout)
                                 throws JIPCException,
                                        java.io.IOException
Get element from the queue with timeout.

Parameters:
rank - processes will be placed in wait queue in the order of increasing rank value and in the same order will be taken from the queue.
timeout - operation timeout in millisoconds
Returns:
null if timeout is expired before any element was placed in the queue.
JIPCException
java.io.IOException

put

public void put(java.io.Serializable obj)
         throws JIPCException,
                java.io.IOException
Put element at the end of the queue.

Parameters:
obj - any not-null serializable object
JIPCException
java.io.IOException

size

public int size()
         throws JIPCException,
                java.io.IOException
Get number of elements in queue

Returns:
number of elements in queue
JIPCException
java.io.IOException