Class FifoDeliveryQueue
java.lang.Object
org.apache.qpid.protonj2.client.util.FifoDeliveryQueue
- All Implemented Interfaces:
DeliveryQueue
Simple first in / first out
Delivery
Queue.-
Constructor Summary
ConstructorDescriptionFifoDeliveryQueue
(int queueDepth) Creates a new first in / first out message queue with the given queue depth -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears the Queue of any queuedDelivery
values.void
close()
Closes the Delivery Queue.dequeue
(long timeout) Used to get anDelivery
.Used to get an enqueuedDelivery
if on exists, otherwise returns null.void
enqueue
(ClientDelivery envelope) Adds the givenDelivery
to the end of the Delivery queue.void
enqueueFirst
(ClientDelivery envelope) Adds the givenDelivery
to the front of the queue.boolean
isClosed()
boolean
isEmpty()
boolean
int
size()
Returns the number of deliveries currently in the Queue.void
start()
Starts the Delivery Queue.void
stop()
Stops the Delivery Queue.toString()
-
Constructor Details
-
FifoDeliveryQueue
public FifoDeliveryQueue(int queueDepth) Creates a new first in / first out message queue with the given queue depth- Parameters:
queueDepth
- The Queue depth to configure for this FIFO Message Queue.
-
-
Method Details
-
enqueueFirst
Description copied from interface:DeliveryQueue
Adds the givenDelivery
to the front of the queue.- Specified by:
enqueueFirst
in interfaceDeliveryQueue
- Parameters:
envelope
- The in-bound Delivery to enqueue.
-
enqueue
Description copied from interface:DeliveryQueue
Adds the givenDelivery
to the end of the Delivery queue.- Specified by:
enqueue
in interfaceDeliveryQueue
- Parameters:
envelope
- The in-bound Delivery to enqueue.
-
dequeue
Description copied from interface:DeliveryQueue
Used to get anDelivery
. The amount of time this method blocks is based on the timeout value that is supplied to it.- If the timeout value is less than zero the dequeue operation blocks until a Delivery is enqueued or the queue is stopped.
- If the timeout value is zero the dequeue operation will not block and will either return the next Delivery on the Queue or null to indicate the queue is empty.
- If the timeout value is greater than zero then the method will either return the next Delivery in the queue or block until the timeout (in milliseconds) has expired or until a new Delivery is placed onto the queue.
- Specified by:
dequeue
in interfaceDeliveryQueue
- Parameters:
timeout
- The amount of time to wait for an entry to be added before returning null.- Returns:
- null if we timeout or if the
Receiver
is closed. - Throws:
InterruptedException
- if the wait is interrupted.
-
dequeueNoWait
Description copied from interface:DeliveryQueue
Used to get an enqueuedDelivery
if on exists, otherwise returns null.- Specified by:
dequeueNoWait
in interfaceDeliveryQueue
- Returns:
- the next Delivery in the Queue if one exists, otherwise null.
-
start
public void start()Description copied from interface:DeliveryQueue
Starts the Delivery Queue. An non-started Queue will always return null for any of the Queue methods.- Specified by:
start
in interfaceDeliveryQueue
-
stop
public void stop()Description copied from interface:DeliveryQueue
Stops the Delivery Queue. Deliveries cannot be read from the Queue when it is in the stopped state and any waiters will be woken.- Specified by:
stop
in interfaceDeliveryQueue
-
close
public void close()Description copied from interface:DeliveryQueue
Closes the Delivery Queue. No Delivery can be added or removed from the Queue once it has entered the closed state.- Specified by:
close
in interfaceDeliveryQueue
-
isRunning
public boolean isRunning()- Specified by:
isRunning
in interfaceDeliveryQueue
- Returns:
- true if the Queue is not in the stopped or closed state.
-
isClosed
public boolean isClosed()- Specified by:
isClosed
in interfaceDeliveryQueue
- Returns:
- true if the Queue has been closed.
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceDeliveryQueue
- Returns:
- true if there are no deliveries in the queue.
-
size
public int size()Description copied from interface:DeliveryQueue
Returns the number of deliveries currently in the Queue. This value is only meaningful at the time of the call as the size of the Queue changes rapidly as deliveries arrive and are consumed.- Specified by:
size
in interfaceDeliveryQueue
- Returns:
- the current number of
Delivery
objects in the Queue.
-
clear
public void clear()Description copied from interface:DeliveryQueue
Clears the Queue of any queuedDelivery
values.- Specified by:
clear
in interfaceDeliveryQueue
-
toString
-