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,
ConsumerContext consumerContext,
SimpleString queueName,
SimpleString filterString,
int priority,
boolean browseOnly,
int initialWindow,
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.
|
Thread |
getCurrentThread() |
SimpleString |
getFilterString() |
long |
getForceDeliveryCount() |
int |
getInitialWindowSize() |
Exception |
getLastException()
Returns the last exception thrown by a call to this consumer's MessageHandler.
|
MessageHandler |
getMessageHandler()
Returns the MessageHandler associated to this consumer.
|
int |
getPriority() |
ClientSession.QueueQuery |
getQueueInfo() |
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 SimpleString FORCED_DELIVERY_MESSAGE
public ClientConsumerImpl(ClientSessionInternal session, ConsumerContext consumerContext, SimpleString queueName, SimpleString filterString, int priority, boolean browseOnly, int initialWindow, int clientWindowSize, int ackBatchSize, TokenBucketLimiter rateLimiter, Executor executor, Executor flowControlExecutor, SessionContext sessionContext, ClientSession.QueueQuery queueInfo, ClassLoader contextClassLoader)
public ConsumerContext getConsumerContext()
ClientConsumer
getConsumerContext
in interface ClientConsumer
public ClientMessage receive(long timeout) throws ActiveMQException
ClientConsumer
This 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 ClientConsumer
timeout
- time (in milliseconds) to wait to receive a messagenull
if the time out expiredActiveMQException
- if an exception occurs while waiting to receive a messagepublic ClientMessage receive() throws ActiveMQException
ClientConsumer
This call will block indefinitely until a message is received.
Calling this method on a closed consumer will throw an ActiveMQException.
receive
in interface ClientConsumer
ActiveMQException
- if an exception occurs while waiting to receive a messagepublic ClientMessage receiveImmediate() throws 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 ClientConsumer
null
if there are no messages in the queue for this consumerActiveMQException
- if an exception occurs while waiting to receive a messagepublic MessageHandler getMessageHandler() throws ActiveMQException
ClientConsumer
Calling this method on a closed consumer will throw an ActiveMQException.
getMessageHandler
in interface ClientConsumer
null
ActiveMQException
- if an exception occurs while getting the MessageHandlerpublic Thread getCurrentThread()
getCurrentThread
in interface ClientConsumerInternal
public ClientConsumerImpl setMessageHandler(MessageHandler theHandler) throws ActiveMQException
ClientConsumer
Calling this method on a closed consumer will throw a ActiveMQException.
setMessageHandler
in interface ClientConsumer
theHandler
- a MessageHandlerActiveMQException
- if an exception occurs while setting the MessageHandlerpublic void close() throws ActiveMQException
ClientConsumer
Once this consumer is closed, it can not receive messages, whether synchronously or asynchronously.
close
in interface AutoCloseable
close
in interface ClientConsumer
ActiveMQException
public Thread prepareForClose(FutureLatch future) throws ActiveMQException
prepareForClose
in interface ClientConsumerInternal
future
- the future to run once the onMessage Thread has completedActiveMQException
public void cleanUp()
cleanUp
in interface ClientConsumerInternal
public boolean isClosed()
ClientConsumer
isClosed
in interface ClientConsumer
true
if this consumer is closed, false
elsepublic void stop(boolean waitForOnMessage) throws ActiveMQException
stop
in interface ClientConsumerInternal
ActiveMQException
public void clearAtFailover()
clearAtFailover
in interface ClientConsumerInternal
public void start()
start
in interface ClientConsumerInternal
public Exception getLastException()
ClientConsumer
getLastException
in interface ClientConsumer
null
public ClientSession.QueueQuery getQueueInfo()
getQueueInfo
in interface ClientConsumerInternal
public long getForceDeliveryCount()
getForceDeliveryCount
in interface ClientConsumerInternal
public SimpleString getFilterString()
getFilterString
in interface ClientConsumerInternal
public int getPriority()
getPriority
in interface ClientConsumerInternal
public SimpleString getQueueName()
getQueueName
in interface ClientConsumerInternal
public boolean isBrowseOnly()
isBrowseOnly
in interface ClientConsumerInternal
public void handleMessage(ClientMessageInternal message) throws Exception
handleMessage
in interface ClientConsumerInternal
Exception
public void handleLargeMessage(ClientLargeMessageInternal clientLargeMessage, long largeMessageSize) throws Exception
handleLargeMessage
in interface ClientConsumerInternal
Exception
public void handleLargeMessageContinuation(byte[] chunk, int flowControlSize, boolean isContinues) throws Exception
handleLargeMessageContinuation
in interface ClientConsumerInternal
Exception
public void clear(boolean waitForOnMessage) throws ActiveMQException
clear
in interface ClientConsumerInternal
ActiveMQException
public int getInitialWindowSize()
getInitialWindowSize
in interface ClientConsumerInternal
public int getClientWindowSize()
getClientWindowSize
in interface ClientConsumerInternal
public int getBufferSize()
getBufferSize
in interface ClientConsumerInternal
public void acknowledge(ClientMessage message) throws ActiveMQException
acknowledge
in interface ClientConsumerInternal
ActiveMQException
public void individualAcknowledge(ClientMessage message) throws ActiveMQException
individualAcknowledge
in interface ClientConsumerInternal
ActiveMQException
public void flushAcks() throws ActiveMQException
flushAcks
in interface ClientConsumerInternal
ActiveMQException
public void flowControl(int messageBytes, boolean discountSlowConsumer) throws ActiveMQException
flowControl
in interface ClientConsumerInternal
discountSlowConsumer
- 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 packetActiveMQException
Copyright © 2019 JBoss by Red Hat. All rights reserved.