public final class ClientConsumerImpl extends Object implements ClientConsumerInternal
| Modifier and Type | Field and Description |
|---|---|
static SimpleString |
FORCED_DELIVERY_MESSAGE |
| Constructor and Description |
|---|
ClientConsumerImpl(ClientSessionInternal session,
long id,
SimpleString queueName,
SimpleString filterString,
boolean browseOnly,
int clientWindowSize,
int ackBatchSize,
TokenBucketLimiter rateLimiter,
Executor executor,
Executor flowControlExecutor,
Channel channel,
SessionQueueQueryResponseMessage queueInfo,
ClassLoader contextClassLoader) |
| Modifier and Type | Method and Description |
|---|---|
void |
acknowledge(ClientMessage message) |
void |
cleanUp() |
void |
clear(boolean waitForOnMessage) |
void |
clearAtFailover() |
void |
close()
Closes the consumer.
|
void |
flowControl(int messageBytes,
boolean discountSlowConsumer)
LargeMessageBuffer will call flowcontrol here, while other handleMessage will also be calling flowControl.
|
void |
flushAcks() |
int |
getBufferSize() |
int |
getClientWindowSize() |
SimpleString |
getFilterString() |
long |
getID() |
Exception |
getLastException()
Returns the last exception thrown by a call to this consumer's MessageHandler.
|
MessageHandler |
getMessageHandler()
Returns the MessageHandler associated to this consumer.
|
SessionQueueQueryResponseMessage |
getQueueInfo() |
SimpleString |
getQueueName() |
void |
handleLargeMessage(SessionReceiveLargeMessage packet) |
void |
handleLargeMessageContinuation(SessionReceiveContinuationMessage chunk) |
void |
handleMessage(SessionReceiveMessage message) |
void |
individualAcknowledge(ClientMessage message) |
boolean |
isBrowseOnly() |
boolean |
isClosed()
Returns whether the consumer is closed or not.
|
Thread |
prepareForClose(FutureLatch future)
To be used by MDBs to stop any more handling of messages.
|
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 theHandler)
Sets the MessageHandler for this consumer to consume messages asynchronously.
|
void |
start() |
void |
stop(boolean waitForOnMessage) |
public static final SimpleString FORCED_DELIVERY_MESSAGE
public ClientConsumerImpl(ClientSessionInternal session, long id, SimpleString queueName, SimpleString filterString, boolean browseOnly, int clientWindowSize, int ackBatchSize, TokenBucketLimiter rateLimiter, Executor executor, Executor flowControlExecutor, Channel channel, SessionQueueQueryResponseMessage queueInfo, ClassLoader contextClassLoader)
public ClientMessage receive(long timeout) throws HornetQException
ClientConsumerThis call will block until a message is received or the given timeout expires.
Calling this method on a closed consumer will throw a HornetQException.
receive in interface ClientConsumertimeout - time (in milliseconds) to wait to receive a messagenull if the time out expiredHornetQException - if an exception occurs while waiting to receive a messagepublic ClientMessage receive() throws HornetQException
ClientConsumerThis call will block indefinitely until a message is received.
Calling this method on a closed consumer will throw a HornetQException.
receive in interface ClientConsumerHornetQException - if an exception occurs while waiting to receive a messagepublic ClientMessage receiveImmediate() throws HornetQException
ClientConsumer
This call will never wait indefinitely for a message, it will return 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.
receiveImmediate in interface ClientConsumernull if there are no messages in the queue for this consumerHornetQException - if an exception occurs while waiting to receive a messagepublic MessageHandler getMessageHandler() throws HornetQException
ClientConsumerCalling this method on a closed consumer will throw a HornetQException.
getMessageHandler in interface ClientConsumernullHornetQException - if an exception occurs while getting the MessageHandlerpublic void setMessageHandler(MessageHandler theHandler) throws HornetQException
ClientConsumerCalling this method on a closed consumer will throw a HornetQException.
setMessageHandler in interface ClientConsumertheHandler - a MessageHandlerHornetQException - if an exception occurs while setting the MessageHandlerpublic void close()
throws HornetQException
ClientConsumerOnce this consumer is closed, it can not receive messages, whether synchronously or asynchronously.
close in interface AutoCloseableclose in interface ClientConsumerHornetQExceptionpublic Thread prepareForClose(FutureLatch future) throws HornetQException
prepareForClose in interface ClientConsumerInternalfuture - the future to run once the onMessage Thread has completedHornetQExceptionpublic void cleanUp()
cleanUp in interface ClientConsumerInternalpublic boolean isClosed()
ClientConsumerisClosed in interface ClientConsumertrue if this consumer is closed, false elsepublic void stop(boolean waitForOnMessage)
throws HornetQException
stop in interface ClientConsumerInternalHornetQExceptionpublic void clearAtFailover()
clearAtFailover in interface ClientConsumerInternalpublic void start()
start in interface ClientConsumerInternalpublic Exception getLastException()
ClientConsumergetLastException in interface ClientConsumernullpublic SessionQueueQueryResponseMessage getQueueInfo()
getQueueInfo in interface ClientConsumerInternalpublic long getID()
getID in interface ClientConsumerInternalpublic SimpleString getFilterString()
getFilterString in interface ClientConsumerInternalpublic SimpleString getQueueName()
getQueueName in interface ClientConsumerInternalpublic boolean isBrowseOnly()
isBrowseOnly in interface ClientConsumerInternalpublic void handleMessage(SessionReceiveMessage message) throws Exception
handleMessage in interface ClientConsumerInternalExceptionpublic void handleLargeMessage(SessionReceiveLargeMessage packet) throws Exception
handleLargeMessage in interface ClientConsumerInternalExceptionpublic void handleLargeMessageContinuation(SessionReceiveContinuationMessage chunk) throws Exception
handleLargeMessageContinuation in interface ClientConsumerInternalExceptionpublic void clear(boolean waitForOnMessage)
throws HornetQException
clear in interface ClientConsumerInternalHornetQExceptionpublic int getClientWindowSize()
getClientWindowSize in interface ClientConsumerInternalpublic int getBufferSize()
getBufferSize in interface ClientConsumerInternalpublic void acknowledge(ClientMessage message) throws HornetQException
acknowledge in interface ClientConsumerInternalHornetQExceptionpublic void individualAcknowledge(ClientMessage message) throws HornetQException
individualAcknowledge in interface ClientConsumerInternalHornetQExceptionpublic void flushAcks()
throws HornetQException
flushAcks in interface ClientConsumerInternalHornetQExceptionpublic void flowControl(int messageBytes,
boolean discountSlowConsumer)
throws HornetQException
flowControl in interface ClientConsumerInternaldiscountSlowConsumer - When dealing with slowConsumers, we need to discount one credit that was pre-sent when the first receive was called. For largeMessage that is only done at the latest packetHornetQExceptionCopyright © 2016 JBoss, a division of Red Hat. All rights reserved.