Package org.apache.qpid.jms.util
Interface MessageQueue
- All Known Implementing Classes:
FifoMessageQueue,PriorityMessageQueue
public interface MessageQueue
Queue based storage interface for inbound Messages.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the Queue of any Messages.voidclose()Closes the Message Queue.dequeue(long timeout) Used to get an enqueued message.Used to get an enqueued Message if on exists, otherwise returns null.voidenqueue(JmsInboundMessageDispatch envelope) Adds the given message envelope to the end of the Message queue.voidenqueueFirst(JmsInboundMessageDispatch envelope) Adds the given message envelope to the front of the Message queue.booleanisClosed()booleanisEmpty()booleanintsize()Returns the number of Messages currently in the Queue.voidstart()Starts the Message Queue.voidstop()Stops the Message Queue.
-
Method Details
-
enqueue
Adds the given message envelope to the end of the Message queue.- Parameters:
envelope- The in-bound Message envelope to enqueue.
-
enqueueFirst
Adds the given message envelope to the front of the Message queue.- Parameters:
envelope- The in-bound Message envelope to enqueue.
-
dequeue
Used to get an enqueued message. The amount of time this method blocks is based on the timeout value. - if timeout==-1 then it blocks until a message is received. - if timeout==0 then it it tries to not block at all, it returns a message if it is available - if timeout > 0 then it blocks up to timeout amount of time. Expired messages will consumed by this method.- 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 consumer is closed.
- Throws:
InterruptedException- if the wait is interrupted.
-
dequeueNoWait
JmsInboundMessageDispatch dequeueNoWait()Used to get an enqueued Message if on exists, otherwise returns null.- Returns:
- the next Message in the Queue if one exists, otherwise null.
-
start
void start()Starts the Message Queue. An non-started Queue will always return null for any of the Queue methods. -
stop
void stop()Stops the Message Queue. Messages cannot be read from the Queue when it is in the stopped state and any waiters will be woken. -
close
void close()Closes the Message Queue. No messages can be added or removed from the Queue once it has entered the closed state. -
isRunning
boolean isRunning()- Returns:
- true if the Queue is not in the stopped or closed state.
-
isClosed
boolean isClosed()- Returns:
- true if the Queue has been closed.
-
isEmpty
boolean isEmpty()- Returns:
- true if there are no messages in the queue.
-
size
int size()Returns the number of Messages currently in the Queue. This value is only meaningful at the time of the call as the size of the Queue changes rapidly as Messages arrive and are consumed.- Returns:
- the current number of Messages in the Queue.
-
clear
void clear()Clears the Queue of any Messages.
-