public final class ClientConsumerImpl extends Object implements ClientConsumerInternal
| Modifier and Type | Field and Description |
|---|---|
static org.apache.activemq.artemis.api.core.SimpleString |
FORCED_DELIVERY_MESSAGE |
| Constructor and Description |
|---|
ClientConsumerImpl(ClientSessionInternal session,
ConsumerContext consumerContext,
org.apache.activemq.artemis.api.core.SimpleString queueName,
org.apache.activemq.artemis.api.core.SimpleString filterString,
boolean browseOnly,
int clientWindowSize,
int ackBatchSize,
TokenBucketLimiter rateLimiter,
Executor executor,
Executor flowControlExecutor,
SessionContext sessionContext,
ClientSession.QueueQuery 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() |
ConsumerContext |
getConsumerContext()
The server's ID associated with this consumer.
|
org.apache.activemq.artemis.api.core.SimpleString |
getFilterString() |
Exception |
getLastException()
Returns the last exception thrown by a call to this consumer's MessageHandler.
|
MessageHandler |
getMessageHandler()
Returns the MessageHandler associated to this consumer.
|
ClientSession.QueueQuery |
getQueueInfo() |
org.apache.activemq.artemis.api.core.SimpleString |
getQueueName() |
void |
handleLargeMessage(ClientLargeMessageInternal clientLargeMessage,
long largeMessageSize) |
void |
handleLargeMessageContinuation(byte[] chunk,
int flowControlSize,
boolean isContinues) |
void |
handleMessage(ClientMessageInternal 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.
|
ClientConsumerImpl |
setMessageHandler(MessageHandler theHandler)
Sets the MessageHandler for this consumer to consume messages asynchronously.
|
void |
start() |
void |
stop(boolean waitForOnMessage) |
String |
toString() |
public static final org.apache.activemq.artemis.api.core.SimpleString FORCED_DELIVERY_MESSAGE
public ClientConsumerImpl(ClientSessionInternal session, ConsumerContext consumerContext, org.apache.activemq.artemis.api.core.SimpleString queueName, org.apache.activemq.artemis.api.core.SimpleString filterString, boolean browseOnly, int clientWindowSize, int ackBatchSize, TokenBucketLimiter rateLimiter, Executor executor, Executor flowControlExecutor, SessionContext sessionContext, ClientSession.QueueQuery queueInfo, ClassLoader contextClassLoader)
public ConsumerContext getConsumerContext()
ClientConsumergetConsumerContext in interface ClientConsumerpublic ClientMessage receive(long timeout) throws org.apache.activemq.artemis.api.core.ActiveMQException
ClientConsumerThis call will block until a message is received or the given timeout expires.
Calling this method on a closed consumer will throw an ActiveMQException.
receive in interface ClientConsumertimeout - time (in milliseconds) to wait to receive a messagenull if the time out expiredorg.apache.activemq.artemis.api.core.ActiveMQException - if an exception occurs while waiting to receive a messagepublic ClientMessage receive() throws org.apache.activemq.artemis.api.core.ActiveMQException
ClientConsumerThis call will block indefinitely until a message is received.
Calling this method on a closed consumer will throw an ActiveMQException.
receive in interface ClientConsumerorg.apache.activemq.artemis.api.core.ActiveMQException - if an exception occurs while waiting to receive a messagepublic ClientMessage receiveImmediate() throws org.apache.activemq.artemis.api.core.ActiveMQException
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 an ActiveMQException.
receiveImmediate in interface ClientConsumernull if there are no messages in the queue for this consumerorg.apache.activemq.artemis.api.core.ActiveMQException - if an exception occurs while waiting to receive a messagepublic MessageHandler getMessageHandler() throws org.apache.activemq.artemis.api.core.ActiveMQException
ClientConsumerCalling this method on a closed consumer will throw an ActiveMQException.
getMessageHandler in interface ClientConsumernullorg.apache.activemq.artemis.api.core.ActiveMQException - if an exception occurs while getting the MessageHandlerpublic ClientConsumerImpl setMessageHandler(MessageHandler theHandler) throws org.apache.activemq.artemis.api.core.ActiveMQException
ClientConsumerCalling this method on a closed consumer will throw a ActiveMQException.
setMessageHandler in interface ClientConsumertheHandler - a MessageHandlerorg.apache.activemq.artemis.api.core.ActiveMQException - if an exception occurs while setting the MessageHandlerpublic void close()
throws org.apache.activemq.artemis.api.core.ActiveMQException
ClientConsumerOnce this consumer is closed, it can not receive messages, whether synchronously or asynchronously.
close in interface AutoCloseableclose in interface ClientConsumerorg.apache.activemq.artemis.api.core.ActiveMQExceptionpublic Thread prepareForClose(FutureLatch future) throws org.apache.activemq.artemis.api.core.ActiveMQException
prepareForClose in interface ClientConsumerInternalfuture - the future to run once the onMessage Thread has completedorg.apache.activemq.artemis.api.core.ActiveMQExceptionpublic void cleanUp()
cleanUp in interface ClientConsumerInternalpublic boolean isClosed()
ClientConsumerisClosed in interface ClientConsumertrue if this consumer is closed, false elsepublic void stop(boolean waitForOnMessage)
throws org.apache.activemq.artemis.api.core.ActiveMQException
stop in interface ClientConsumerInternalorg.apache.activemq.artemis.api.core.ActiveMQExceptionpublic void clearAtFailover()
clearAtFailover in interface ClientConsumerInternalpublic void start()
start in interface ClientConsumerInternalpublic Exception getLastException()
ClientConsumergetLastException in interface ClientConsumernullpublic ClientSession.QueueQuery getQueueInfo()
getQueueInfo in interface ClientConsumerInternalpublic org.apache.activemq.artemis.api.core.SimpleString getFilterString()
getFilterString in interface ClientConsumerInternalpublic org.apache.activemq.artemis.api.core.SimpleString getQueueName()
getQueueName in interface ClientConsumerInternalpublic boolean isBrowseOnly()
isBrowseOnly in interface ClientConsumerInternalpublic void handleMessage(ClientMessageInternal message) throws Exception
handleMessage in interface ClientConsumerInternalExceptionpublic void handleLargeMessage(ClientLargeMessageInternal clientLargeMessage, long largeMessageSize) throws Exception
handleLargeMessage in interface ClientConsumerInternalExceptionpublic void handleLargeMessageContinuation(byte[] chunk,
int flowControlSize,
boolean isContinues)
throws Exception
handleLargeMessageContinuation in interface ClientConsumerInternalExceptionpublic void clear(boolean waitForOnMessage)
throws org.apache.activemq.artemis.api.core.ActiveMQException
clear in interface ClientConsumerInternalorg.apache.activemq.artemis.api.core.ActiveMQExceptionpublic int getClientWindowSize()
getClientWindowSize in interface ClientConsumerInternalpublic int getBufferSize()
getBufferSize in interface ClientConsumerInternalpublic void acknowledge(ClientMessage message) throws org.apache.activemq.artemis.api.core.ActiveMQException
acknowledge in interface ClientConsumerInternalorg.apache.activemq.artemis.api.core.ActiveMQExceptionpublic void individualAcknowledge(ClientMessage message) throws org.apache.activemq.artemis.api.core.ActiveMQException
individualAcknowledge in interface ClientConsumerInternalorg.apache.activemq.artemis.api.core.ActiveMQExceptionpublic void flushAcks()
throws org.apache.activemq.artemis.api.core.ActiveMQException
flushAcks in interface ClientConsumerInternalorg.apache.activemq.artemis.api.core.ActiveMQExceptionpublic void flowControl(int messageBytes,
boolean discountSlowConsumer)
throws org.apache.activemq.artemis.api.core.ActiveMQException
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 packetorg.apache.activemq.artemis.api.core.ActiveMQExceptionCopyright © 2023 The Apache Software Foundation. All rights reserved.