|
|||||||||
Home >> All >> org >> [ activemq overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |
org.activemq
Class ActiveMQMessageConsumer

java.lang.Objectorg.activemq.ActiveMQMessageConsumer
- All Implemented Interfaces:
- Closeable, javax.jms.MessageConsumer, org.activemq.management.StatsCapable
- Direct Known Subclasses:
- ActiveMQQueueReceiver, ActiveMQTopicSubscriber
- public class ActiveMQMessageConsumer
- extends java.lang.Object
- implements javax.jms.MessageConsumer, org.activemq.management.StatsCapable, Closeable
- extends java.lang.Object
A client uses a MessageConsumer
object to receive messages from a destination. A
MessageConsumer
object is created by passing a Destination
object to a message-consumer
creation method supplied by a session.
MessageConsumer
is the parent interface for all message consumers.
A message consumer can be created with a message selector. A message selector allows the client to restrict the messages delivered to the message consumer to those that match the selector.
A client may either synchronously receive a message consumer's messages or have the consumer asynchronously deliver them as they arrive.
For synchronous receipt, a client can request the next message from a message consumer using one of its
receive
methods. There are several variations of receive
that allow a client to poll or wait
for the next message.
For asynchronous delivery, a client can register a MessageListener
object with a message consumer. As
messages arrive at the message consumer, it delivers them by calling the MessageListener
's
onMessage
method.
It is a client programming error for a MessageListener
to throw an exception.
- Version:
- $Revision: 1.1.1.1 $
Field Summary | |
private java.lang.Thread |
accessThread
|
protected boolean |
browser
|
private boolean |
closed
|
protected java.lang.String |
consumerIdentifier
|
protected java.lang.String |
consumerName
|
protected int |
consumerNumber
|
protected org.activemq.message.ActiveMQDestination |
destination
|
private static org.apache.commons.logging.Log |
log
|
private javax.jms.MessageListener |
messageListener
|
private java.lang.Object |
messageListenerGuard
|
protected org.activemq.io.util.MemoryBoundedQueue |
messageQueue
|
protected java.lang.String |
messageSelector
|
protected boolean |
noLocal
|
protected int |
prefetchNumber
|
private SynchronizedBoolean |
running
|
protected ActiveMQSession |
session
|
protected long |
startTime
|
private org.activemq.management.JMSConsumerStatsImpl |
stats
|
private java.util.LinkedList |
stoppedQueue
|
Constructor Summary | |
protected |
ActiveMQMessageConsumer(ActiveMQSession theSession,
org.activemq.message.ActiveMQDestination dest,
java.lang.String name,
java.lang.String selector,
int cnum,
int prefetch,
boolean noLocalValue,
boolean browserValue)
Create a MessageConsumer |
Method Summary | |
private void |
afterMessageDelivered(org.activemq.message.ActiveMQMessage message,
boolean messageRead,
boolean messageExpired,
boolean beforeCalled)
|
private void |
beforeMessageDelivered(org.activemq.message.ActiveMQMessage message)
|
protected void |
checkClosed()
|
protected void |
clearMessagesInProgress()
|
void |
close()
Closes the message consumer. |
protected java.lang.String |
getConsumerIdentifier()
|
protected java.lang.String |
getConsumerName()
|
protected int |
getConsumerNumber()
|
org.activemq.management.JMSConsumerStatsImpl |
getConsumerStats()
|
protected org.activemq.message.ActiveMQDestination |
getDestination()
|
long |
getLocalMemoryUsage()
|
javax.jms.MessageListener |
getMessageListener()
Gets the message consumer's MessageListener . |
java.lang.String |
getMessageSelector()
Gets this message consumer's message selector expression. |
int |
getPrefetchNumber()
|
protected long |
getStartTime()
|
org.activemq.management.StatsImpl |
getStats()
|
protected boolean |
isBrowser()
Retrive is a browser |
boolean |
isDurableSubscriber()
|
protected boolean |
isNoLocal()
|
boolean |
isTransientSubscriber()
|
private void |
messageDelivered(org.activemq.message.ActiveMQMessage message,
boolean messageRead,
boolean messageExpired)
|
protected void |
processMessage(org.activemq.message.ActiveMQMessage message)
Process a Message - passing either to the queue or message listener |
javax.jms.Message |
receive()
Receives the next message produced for this message consumer. |
javax.jms.Message |
receive(long timeout)
Receives the next message that arrives within the specified timeout interval. |
javax.jms.Message |
receiveNoWait()
Receives the next message if one is immediately available. |
protected void |
setBrowser(boolean value)
Set true if only a Browser |
protected void |
setConsumerName(java.lang.String value)
Set the name of the Consumer - used for durable subscribers |
protected void |
setConsumerNumber(int value)
Set the locally unique consumer number |
void |
setMessageListener(javax.jms.MessageListener listener)
Sets the message consumer's MessageListener . |
void |
setPrefetchNumber(int prefetchNumber)
|
int |
size()
|
void |
start()
|
void |
stop()
|
java.lang.String |
toString()
Convert this Object to a human-readable String. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
log
private static final org.apache.commons.logging.Log log
session
protected ActiveMQSession session
consumerIdentifier
protected java.lang.String consumerIdentifier
messageQueue
protected org.activemq.io.util.MemoryBoundedQueue messageQueue
messageSelector
protected java.lang.String messageSelector
messageListener
private javax.jms.MessageListener messageListener
consumerName
protected java.lang.String consumerName
destination
protected org.activemq.message.ActiveMQDestination destination
closed
private boolean closed
consumerNumber
protected int consumerNumber
prefetchNumber
protected int prefetchNumber
startTime
protected long startTime
noLocal
protected boolean noLocal
browser
protected boolean browser
accessThread
private java.lang.Thread accessThread
messageListenerGuard
private java.lang.Object messageListenerGuard
stats
private org.activemq.management.JMSConsumerStatsImpl stats
running
private SynchronizedBoolean running
stoppedQueue
private java.util.LinkedList stoppedQueue
Constructor Detail |
ActiveMQMessageConsumer
protected ActiveMQMessageConsumer(ActiveMQSession theSession, org.activemq.message.ActiveMQDestination dest, java.lang.String name, java.lang.String selector, int cnum, int prefetch, boolean noLocalValue, boolean browserValue) throws javax.jms.JMSException
- Create a MessageConsumer
Method Detail |
getLocalMemoryUsage
public long getLocalMemoryUsage()
size
public int size()
getStats
public org.activemq.management.StatsImpl getStats()
- Specified by:
getStats
in interfaceorg.activemq.management.StatsCapable
getConsumerStats
public org.activemq.management.JMSConsumerStatsImpl getConsumerStats()
toString
public java.lang.String toString()
- Description copied from class:
java.lang.Object
- Convert this Object to a human-readable String.
There are no limits placed on how long this String
should be or what it should contain. We suggest you
make it as intuitive as possible to be able to place
it into System.out.println() 55
and such.
It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.
This method will be called when performing string concatenation with this object. If the result is
null
, string concatenation will instead use"null"
.The default implementation returns
getClass().getName() + "@" + Integer.toHexString(hashCode())
.
getPrefetchNumber
public int getPrefetchNumber()
setPrefetchNumber
public void setPrefetchNumber(int prefetchNumber)
getMessageSelector
public java.lang.String getMessageSelector() throws javax.jms.JMSException
- Gets this message consumer's message selector expression.
- Specified by:
getMessageSelector
in interfacejavax.jms.MessageConsumer
getMessageListener
public javax.jms.MessageListener getMessageListener() throws javax.jms.JMSException
- Gets the message consumer's
MessageListener
.- Specified by:
getMessageListener
in interfacejavax.jms.MessageConsumer
setMessageListener
public void setMessageListener(javax.jms.MessageListener listener) throws javax.jms.JMSException
- Sets the message consumer's
MessageListener
.Setting the message listener to null is the equivalent of unsetting the message listener for the message consumer.
The effect of calling
MessageConsumer.setMessageListener
while messages are being consumed by an existing listener or the consumer is being used to consume messages synchronously is undefined.- Specified by:
setMessageListener
in interfacejavax.jms.MessageConsumer
receive
public javax.jms.Message receive() throws javax.jms.JMSException
- Receives the next message produced for this message consumer.
This call blocks indefinitely until a message is produced or until this message consumer is closed.
If this
receive
is done within a transaction, the consumer retains the message until the transaction commits.- Specified by:
receive
in interfacejavax.jms.MessageConsumer
receive
public javax.jms.Message receive(long timeout) throws javax.jms.JMSException
- Receives the next message that arrives within the specified timeout interval.
This call blocks until a message arrives, the timeout expires, or this message consumer is closed. A
timeout
of zero never expires, and the call blocks indefinitely.- Specified by:
receive
in interfacejavax.jms.MessageConsumer
receiveNoWait
public javax.jms.Message receiveNoWait() throws javax.jms.JMSException
- Receives the next message if one is immediately available.
- Specified by:
receiveNoWait
in interfacejavax.jms.MessageConsumer
close
public void close() throws javax.jms.JMSException
- Closes the message consumer.
Since a provider may allocate some resources on behalf of a
MessageConsumer
outside the Java virtual machine, clients should close them when they are not needed. Relying on garbage collection to eventually reclaim these resources may not be timely enough.This call blocks until a
receive
or message listener in progress has completed. A blocked message consumerreceive
call returns null when this message consumer is closed.- Specified by:
close
in interfacejavax.jms.MessageConsumer
isDurableSubscriber
public boolean isDurableSubscriber()
isTransientSubscriber
public boolean isTransientSubscriber()
checkClosed
protected void checkClosed() throws javax.jms.IllegalStateException
processMessage
protected void processMessage(org.activemq.message.ActiveMQMessage message)
- Process a Message - passing either to the queue or message listener
getConsumerIdentifier
protected java.lang.String getConsumerIdentifier()
getConsumerName
protected java.lang.String getConsumerName()
setConsumerName
protected void setConsumerName(java.lang.String value)
- Set the name of the Consumer - used for durable subscribers
getConsumerNumber
protected int getConsumerNumber()
setConsumerNumber
protected void setConsumerNumber(int value)
- Set the locally unique consumer number
isNoLocal
protected boolean isNoLocal()
isBrowser
protected boolean isBrowser()
- Retrive is a browser
setBrowser
protected void setBrowser(boolean value)
- Set true if only a Browser
getDestination
protected org.activemq.message.ActiveMQDestination getDestination()
getStartTime
protected long getStartTime()
clearMessagesInProgress
protected void clearMessagesInProgress()
messageDelivered
private void messageDelivered(org.activemq.message.ActiveMQMessage message, boolean messageRead, boolean messageExpired)
beforeMessageDelivered
private void beforeMessageDelivered(org.activemq.message.ActiveMQMessage message)
afterMessageDelivered
private void afterMessageDelivered(org.activemq.message.ActiveMQMessage message, boolean messageRead, boolean messageExpired, boolean beforeCalled)
start
public void start()
stop
public void stop()
|
|||||||||
Home >> All >> org >> [ activemq overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |