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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
clear()
Clears the Queue of any Messages.void
close()
Closes the Message Queue.JmsInboundMessageDispatch
dequeue(long timeout)
Used to get an enqueued message.JmsInboundMessageDispatch
dequeueNoWait()
Used to get an enqueued Message if on exists, otherwise returns null.void
enqueue(JmsInboundMessageDispatch envelope)
Adds the given message envelope to the end of the Message queue.void
enqueueFirst(JmsInboundMessageDispatch envelope)
Adds the given message envelope to the front of the Message queue.boolean
isClosed()
boolean
isEmpty()
boolean
isRunning()
int
size()
Returns the number of Messages currently in the Queue.void
start()
Starts the Message Queue.void
stop()
Stops the Message Queue.
-
-
-
Method Detail
-
enqueue
void enqueue(JmsInboundMessageDispatch envelope)
Adds the given message envelope to the end of the Message queue.- Parameters:
envelope
- The in-bound Message envelope to enqueue.
-
enqueueFirst
void enqueueFirst(JmsInboundMessageDispatch envelope)
Adds the given message envelope to the front of the Message queue.- Parameters:
envelope
- The in-bound Message envelope to enqueue.
-
dequeue
JmsInboundMessageDispatch dequeue(long timeout) throws java.lang.InterruptedException
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:
java.lang.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.
-
-