public class JmsMessageConsumer extends Object implements AutoCloseable, javax.jms.MessageConsumer, JmsMessageAvailableConsumer, JmsMessageDispatcher
Modifier and Type | Field and Description |
---|---|
protected int |
acknowledgementMode |
protected JmsMessageAvailableListener |
availableListener |
protected AtomicBoolean |
closed |
protected JmsConnection |
connection |
protected JmsConsumerInfo |
consumerInfo |
protected AtomicReference<Exception> |
failureCause |
protected Lock |
lock |
protected javax.jms.MessageListener |
messageListener |
protected MessageQueue |
messageQueue |
protected JmsSession |
session |
protected boolean |
started |
protected AtomicBoolean |
suspendedConnection |
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() |
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) |
javax.jms.Message |
receiveNoWait() |
protected boolean |
redeliveryExceeded(JmsInboundMessageDispatch envelope) |
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(Exception 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 boolean started
protected javax.jms.MessageListener messageListener
protected JmsMessageAvailableListener availableListener
protected final MessageQueue messageQueue
protected final Lock lock
protected final AtomicBoolean suspendedConnection
protected final AtomicReference<Exception> failureCause
protected JmsMessageConsumer(JmsConsumerId consumerId, JmsSession session, JmsDestination destination, String selector, boolean noLocal) throws javax.jms.JMSException
javax.jms.JMSException
protected JmsMessageConsumer(JmsConsumerId consumerId, JmsSession session, JmsDestination destination, String name, String selector, boolean noLocal) throws javax.jms.JMSException
javax.jms.JMSException
public void init() throws javax.jms.JMSException
javax.jms.JMSException
public void close() throws javax.jms.JMSException
close
in interface AutoCloseable
close
in interface javax.jms.MessageConsumer
javax.jms.JMSException
protected 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(Exception cause) throws javax.jms.JMSException
javax.jms.JMSException
public javax.jms.Message receive() throws javax.jms.JMSException
receive
in interface javax.jms.MessageConsumer
javax.jms.JMSException
public javax.jms.Message receive(long timeout) throws javax.jms.JMSException
receive
in interface javax.jms.MessageConsumer
javax.jms.JMSException
public javax.jms.Message receiveNoWait() throws javax.jms.JMSException
receiveNoWait
in interface javax.jms.MessageConsumer
javax.jms.JMSException
protected boolean redeliveryExceeded(JmsInboundMessageDispatch envelope)
protected void checkClosed() throws javax.jms.IllegalStateException
javax.jms.IllegalStateException
public void onInboundMessage(JmsInboundMessageDispatch envelope)
onInboundMessage
in interface JmsMessageDispatcher
envelope
- 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.MessageConsumer
javax.jms.JMSException
public void setMessageListener(javax.jms.MessageListener listener) throws javax.jms.JMSException
setMessageListener
in interface javax.jms.MessageConsumer
javax.jms.JMSException
public String getMessageSelector() throws javax.jms.JMSException
getMessageSelector
in interface javax.jms.MessageConsumer
javax.jms.JMSException
public int getPrefetchSize()
protected void checkMessageListener() throws javax.jms.JMSException
javax.jms.JMSException
protected int getMessageQueueSize()
protected boolean isNoLocal()
public boolean isDurableSubscription()
public boolean isBrowser()
public boolean isPullConsumer()
public void setAvailableListener(JmsMessageAvailableListener availableListener)
JmsMessageAvailableConsumer
MessageConsumer.receiveNoWait()
can be called.setAvailableListener
in interface JmsMessageAvailableConsumer
availableListener
- the JmsMessageAvailableListener instance to signal.public JmsMessageAvailableListener getAvailableListener()
JmsMessageAvailableConsumer
MessageConsumer.receiveNoWait()
can be called.getAvailableListener
in interface JmsMessageAvailableConsumer
protected void onConnectionInterrupted()
protected void onConnectionRecovery(Provider provider) throws Exception
Exception
protected void onConnectionRecovered(Provider provider) throws Exception
Exception
protected 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.JMSException
Copyright © 2013–2016 The Apache Software Foundation. All rights reserved.