public class JmsMessageConsumer extends Object implements AutoCloseable, javax.jms.MessageConsumer, JmsMessageAvailableConsumer, JmsMessageDispatcher
| Modifier and Type | Field and Description |
|---|---|
protected int |
acknowledgementMode |
protected String |
address |
protected JmsMessageAvailableListener |
availableListener |
protected AtomicBoolean |
closed |
protected JmsConnection |
connection |
protected JmsConsumerInfo |
consumerInfo |
protected org.apache.qpid.jms.JmsMessageConsumer.MessageDeliverTask |
deliveryTask |
protected Lock |
dispatchLock |
protected AtomicReference<Throwable> |
failureCause |
protected Lock |
lock |
protected javax.jms.MessageListener |
messageListener |
protected MessageQueue |
messageQueue |
protected JmsSession |
session |
protected JmsTracer |
tracer |
| Modifier | Constructor and Description |
|---|---|
protected |
JmsMessageConsumer(JmsConsumerId consumerId,
JmsSession session,
JmsDestination destination,
String selector,
boolean noLocal) |
protected |
JmsMessageConsumer(JmsConsumerId consumerId,
JmsSession session,
JmsDestination destination,
String name,
String selector,
boolean noLocal) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkClosed() |
protected void |
checkMessageListener() |
void |
close() |
protected void |
doClose()
Called to initiate shutdown of Producer resources and request that the remote
peer remove the registered producer.
|
JmsMessageAvailableListener |
getAvailableListener()
Gets the listener used to notify synchronous consumers that there is a message
available so that the
MessageConsumer.receiveNoWait() can be called. |
JmsConsumerId |
getConsumerId() |
JmsDestination |
getDestination() |
javax.jms.MessageListener |
getMessageListener() |
protected int |
getMessageQueueSize() |
String |
getMessageSelector() |
int |
getPrefetchSize()
Gets the configured prefetch size for this consumer.
|
void |
init() |
boolean |
isBrowser() |
boolean |
isDurableSubscription() |
protected boolean |
isNoLocal() |
boolean |
isPullConsumer() |
boolean |
isSharedSubscription() |
protected void |
onConnectionInterrupted() |
protected void |
onConnectionRecovered(Provider provider) |
protected void |
onConnectionRecovery(Provider provider) |
protected void |
onConnectionRestored() |
void |
onInboundMessage(JmsInboundMessageDispatch envelope)
Called from the session when a new Message has been dispatched to this Consumer
from the connection.
|
protected boolean |
performPullIfRequired(long timeout,
boolean treatAsPullConsumer)
Triggers a pull request from the connected Provider with the given timeout value
if the consumer is a pull consumer or requested to be treated as one, and the
local queue is still running, and is currently empty.
|
javax.jms.Message |
receive() |
javax.jms.Message |
receive(long timeout) |
<T> T |
receiveBody(Class<T> desired,
long timeout)
Reads the next available message for this consumer and returns the body of that message
if the type requested matches that of the message.
|
javax.jms.Message |
receiveNoWait() |
void |
setAvailableListener(JmsMessageAvailableListener availableListener)
Sets the listener used to notify synchronous consumers that there is a message
available so that the
MessageConsumer.receiveNoWait() can be called. |
void |
setMessageListener(javax.jms.MessageListener listener) |
protected void |
shutdown()
Called to release all producer resources without requiring a destroy request
to be sent to the remote peer.
|
protected void |
shutdown(Throwable cause) |
void |
start() |
void |
stop() |
protected final JmsSession session
protected final JmsConnection connection
protected JmsConsumerInfo consumerInfo
protected final int acknowledgementMode
protected final AtomicBoolean closed
protected volatile javax.jms.MessageListener messageListener
protected volatile JmsMessageAvailableListener availableListener
protected final MessageQueue messageQueue
protected final Lock lock
protected final Lock dispatchLock
protected final AtomicReference<Throwable> failureCause
protected final org.apache.qpid.jms.JmsMessageConsumer.MessageDeliverTask deliveryTask
protected final JmsTracer tracer
protected final String address
protected JmsMessageConsumer(JmsConsumerId consumerId, JmsSession session, JmsDestination destination, String selector, boolean noLocal) throws javax.jms.JMSException
javax.jms.JMSExceptionprotected JmsMessageConsumer(JmsConsumerId consumerId, JmsSession session, JmsDestination destination, String name, String selector, boolean noLocal) throws javax.jms.JMSException
javax.jms.JMSExceptionpublic void init()
throws javax.jms.JMSException
javax.jms.JMSExceptionpublic void close()
throws javax.jms.JMSException
close in interface AutoCloseableclose in interface javax.jms.MessageConsumerjavax.jms.JMSExceptionprotected void doClose()
throws javax.jms.JMSException
javax.jms.JMSException - if an error occurs during the consumer close operation.protected void shutdown()
throws javax.jms.JMSException
javax.jms.JMSException - if an error occurs during shutdown.protected void shutdown(Throwable cause) throws javax.jms.JMSException
javax.jms.JMSExceptionpublic javax.jms.Message receive()
throws javax.jms.JMSException
receive in interface javax.jms.MessageConsumerjavax.jms.JMSExceptionpublic javax.jms.Message receive(long timeout)
throws javax.jms.JMSException
receive in interface javax.jms.MessageConsumerjavax.jms.JMSExceptionpublic javax.jms.Message receiveNoWait()
throws javax.jms.JMSException
receiveNoWait in interface javax.jms.MessageConsumerjavax.jms.JMSExceptionpublic <T> T receiveBody(Class<T> desired, long timeout) throws javax.jms.JMSException
desired - The type to assign the body of the message to for return.timeout - The time to wait for an incoming message before this method returns null.javax.jms.MessageFormatException - if the message body cannot be assigned to the requested type.javax.jms.JMSException - if an error occurs while receiving the next message.protected void checkClosed()
throws javax.jms.IllegalStateException
javax.jms.IllegalStateExceptionpublic void onInboundMessage(JmsInboundMessageDispatch envelope)
onInboundMessage in interface JmsMessageDispatcherenvelope - the newly arrived message.public void start()
public void stop()
public JmsConsumerId getConsumerId()
public JmsDestination getDestination()
public javax.jms.MessageListener getMessageListener()
throws javax.jms.JMSException
getMessageListener in interface javax.jms.MessageConsumerjavax.jms.JMSExceptionpublic void setMessageListener(javax.jms.MessageListener listener)
throws javax.jms.JMSException
setMessageListener in interface javax.jms.MessageConsumerjavax.jms.JMSExceptionpublic String getMessageSelector() throws javax.jms.JMSException
getMessageSelector in interface javax.jms.MessageConsumerjavax.jms.JMSExceptionpublic int getPrefetchSize()
protected void checkMessageListener()
throws javax.jms.JMSException
javax.jms.JMSExceptionprotected int getMessageQueueSize()
protected boolean isNoLocal()
public boolean isDurableSubscription()
public boolean isSharedSubscription()
public boolean isBrowser()
public boolean isPullConsumer()
public void setAvailableListener(JmsMessageAvailableListener availableListener)
JmsMessageAvailableConsumerMessageConsumer.receiveNoWait() can be called.setAvailableListener in interface JmsMessageAvailableConsumeravailableListener - the JmsMessageAvailableListener instance to signal.public JmsMessageAvailableListener getAvailableListener()
JmsMessageAvailableConsumerMessageConsumer.receiveNoWait() can be called.getAvailableListener in interface JmsMessageAvailableConsumerprotected void onConnectionInterrupted()
protected void onConnectionRecovery(Provider provider) throws Exception
Exceptionprotected void onConnectionRecovered(Provider provider) throws Exception
Exceptionprotected void onConnectionRestored()
protected boolean performPullIfRequired(long timeout,
boolean treatAsPullConsumer)
throws javax.jms.JMSException
The timeout value can be one of:
< 0 to indicate that the request should never time out.
= 0 to indicate that the request should expire immediately if no message.
> 0 to indicate that the request should expire after the given time in milliseconds.
timeout - The amount of time the pull request should remain valid.treatAsPullConsumer - Treat the consumer as if it were a pull consumer, even if it isn't.javax.jms.JMSExceptionCopyright © 2013–2019 The Apache Software Foundation. All rights reserved.