|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ClientConsumer
A ClientConsumer receives messages from HornetQ queues.
Messages can be consumed synchronously by using the receive()
methods
which will block until a message is received (or a timeout expires) or asynchronously
by setting a MessageHandler
.
These 2 types of consumption are exclusive: a ClientConsumer with a MessageHandler set will
throw HornetQException if its receive()
methods are called.
ClientSession.createConsumer(String)
Method Summary | |
---|---|
void |
close()
Closes the consumer. |
Exception |
getLastException()
Returns the last exception thrown by a call to this consumer's MessageHandler. |
MessageHandler |
getMessageHandler()
Returns the MessageHandler associated to this consumer. |
boolean |
isClosed()
Returns whether the consumer is closed or not. |
ClientMessage |
receive()
Receives a message from a queue. |
ClientMessage |
receive(long timeout)
Receives a message from a queue. |
ClientMessage |
receiveImmediate()
Receives a message from a queue. |
void |
setMessageHandler(MessageHandler handler)
Sets the MessageHandler for this consumer to consume messages asynchronously. |
Method Detail |
---|
ClientMessage receive() throws HornetQException
HornetQException
- if an exception occurs while waiting to receive a messageClientMessage receive(long timeout) throws HornetQException
timeout
- time (in milliseconds) to wait to receive a message
null
if the time out expired
HornetQException
- if an exception occurs while waiting to receive a messageClientMessage receiveImmediate() throws HornetQException
null
if no messages are available for this consumer.
Note however that there is a performance cost as an additional network trip to the
server may required to check the queue status.
Calling this method on a closed consumer will throw a HornetQException.
null
if there are no messages in the queue for this consumer
HornetQException
- if an exception occurs while waiting to receive a messageMessageHandler getMessageHandler() throws HornetQException
null
HornetQException
- if an exception occurs while getting the MessageHandlervoid setMessageHandler(MessageHandler handler) throws HornetQException
handler
- a MessageHandler
HornetQException
- if an exception occurs while setting the MessageHandlervoid close() throws HornetQException
HornetQException
boolean isClosed()
true
if this consumer is closed, false
elseException getLastException()
null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |