org.codehaus.activemq.message.util
Class SpooledBoundedPacketQueue

java.lang.Object
  extended byorg.codehaus.activemq.message.util.SpooledBoundedPacketQueue
All Implemented Interfaces:
BoundedPacketQueue

public class SpooledBoundedPacketQueue
extends Object
implements BoundedPacketQueue

Implements a controlled thread safe queue, with Packets being spooled to disk for reading asynchronously.


Constructor Summary
SpooledBoundedPacketQueue(File dir, String name)
          Constructor for SpooledBoundedPacketQueue
SpooledBoundedPacketQueue(File dir, String name, long maxDataLength, int maxBlockSize)
          Constructor for SpooledBoundedPacketQueue
 
Method Summary
 void clear()
          clear the queue
 void close()
          close this queue
 Packet dequeue()
           
 Packet dequeue(long timeInMillis)
          Dequeues a Packet from the head of the queue
 Packet dequeueNoWait()
          dequeues a Packet from the head of the queue
 void enqueue(Packet packet)
          Place a Packet at the head of the Queue
 void enqueueNoBlock(Packet packet)
          Enqueue a Packet without checking usage limits
 List getContents()
          Retrieve a shallow copy of the contents as a list
 String getName()
           
 boolean isEmpty()
           
 boolean isFull()
           
 boolean isStarted()
           
 int size()
           
 void start()
          enable dequeueing
 void stop()
          disable dequeueing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpooledBoundedPacketQueue

public SpooledBoundedPacketQueue(File dir,
                                 String name,
                                 long maxDataLength,
                                 int maxBlockSize)
                          throws IOException
Constructor for SpooledBoundedPacketQueue

Parameters:
dir -
name -
maxDataLength -
maxBlockSize -
Throws:
IOException

SpooledBoundedPacketQueue

public SpooledBoundedPacketQueue(File dir,
                                 String name)
                          throws IOException
Constructor for SpooledBoundedPacketQueue

Parameters:
dir -
name -
Throws:
IOException
Method Detail

enqueue

public void enqueue(Packet packet)
             throws JMSException
Place a Packet at the head of the Queue

Specified by:
enqueue in interface BoundedPacketQueue
Parameters:
packet -
Throws:
JMSException

enqueueNoBlock

public void enqueueNoBlock(Packet packet)
                    throws JMSException
Enqueue a Packet without checking usage limits

Specified by:
enqueueNoBlock in interface BoundedPacketQueue
Parameters:
packet -
Throws:
JMSException

dequeue

public Packet dequeue()
               throws JMSException,
                      InterruptedException
Specified by:
dequeue in interface BoundedPacketQueue
Returns:
the first dequeued Packet or blocks until one is available
Throws:
JMSException
InterruptedException

dequeue

public Packet dequeue(long timeInMillis)
               throws JMSException,
                      InterruptedException
Description copied from interface: BoundedPacketQueue
Dequeues a Packet from the head of the queue

Specified by:
dequeue in interface BoundedPacketQueue
Parameters:
timeInMillis - maximum time to wait to dequeue a Packet
Returns:
the Packet from the head of the Queue or null if the Queue is empty
Throws:
JMSException
InterruptedException

dequeueNoWait

public Packet dequeueNoWait()
                     throws JMSException,
                            InterruptedException
Description copied from interface: BoundedPacketQueue
dequeues a Packet from the head of the queue

Specified by:
dequeueNoWait in interface BoundedPacketQueue
Returns:
the Packet from the head of the Queue or null if the Queue is empty
Throws:
JMSException
InterruptedException

isFull

public boolean isFull()
Returns:
true if this queue has reached it's data length limit

close

public void close()
close this queue

Specified by:
close in interface BoundedPacketQueue

getName

public String getName()
Specified by:
getName in interface BoundedPacketQueue
Returns:
the name of this BoundedPacketQueue

size

public int size()
Specified by:
size in interface BoundedPacketQueue
Returns:
number of Packets held by this queue

isStarted

public boolean isStarted()
Specified by:
isStarted in interface BoundedPacketQueue
Returns:
true if the queue is enabled for dequeing (default = true)

stop

public void stop()
disable dequeueing

Specified by:
stop in interface BoundedPacketQueue

start

public void start()
enable dequeueing

Specified by:
start in interface BoundedPacketQueue

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface BoundedPacketQueue
Returns:
true if this queue is empty

clear

public void clear()
clear the queue

Specified by:
clear in interface BoundedPacketQueue

getContents

public List getContents()
Description copied from interface: BoundedPacketQueue
Retrieve a shallow copy of the contents as a list

Specified by:
getContents in interface BoundedPacketQueue
Returns:
a copy of the contents


Copyright © 2004 Protique, Ltd.. All Rights Reserved.