|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.activemq.ActiveMQMessageConsumer
public class ActiveMQMessageConsumer
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.
MessageConsumer,
QueueReceiver,
TopicSubscriber,
Session| Field Summary | |
|---|---|
protected LinkedList<MessageDispatch> |
deliveredMessages
|
protected ConsumerInfo |
info
|
protected ActiveMQSession |
session
|
protected MessageDispatchChannel |
unconsumedMessages
|
| Constructor Summary | |
|---|---|
ActiveMQMessageConsumer(ActiveMQSession session,
ConsumerId consumerId,
ActiveMQDestination dest,
String name,
String selector,
int prefetch,
int maximumPendingMessageCount,
boolean noLocal,
boolean browser,
boolean dispatchAsync,
javax.jms.MessageListener messageListener)
Create a MessageConsumer |
|
| Method Summary | |
|---|---|
void |
acknowledge()
Acknowledge all the messages that have been delivered to the client up to this point. |
protected void |
checkClosed()
|
protected void |
checkMessageListener()
|
void |
close()
Closes the message consumer. |
void |
commit()
|
void |
dispatch(MessageDispatch md)
|
void |
dispose()
|
MessageAvailableListener |
getAvailableListener()
Gets the listener used to notify synchronous consumers that there is a message available so that the MessageConsumer.receiveNoWait() can be called. |
ConsumerId |
getConsumerId()
|
String |
getConsumerName()
|
JMSConsumerStatsImpl |
getConsumerStats()
|
protected ActiveMQDestination |
getDestination()
|
IOException |
getFailureError()
|
long |
getLastDeliveredSequenceId()
|
javax.jms.MessageListener |
getMessageListener()
Gets the message consumer's MessageListener. |
String |
getMessageSelector()
Gets this message consumer's message selector expression. |
int |
getMessageSize()
|
long |
getOptimizedAckScheduledAckInterval()
|
int |
getPrefetchNumber()
|
RedeliveryPolicy |
getRedeliveryPolicy()
|
StatsImpl |
getStats()
|
MessageTransformer |
getTransformer()
|
boolean |
hasMessageListener()
|
protected boolean |
isBrowser()
Retrieve is a browser |
boolean |
isDurableSubscriber()
|
boolean |
isInUse(ActiveMQTempDestination destination)
|
protected boolean |
isNoLocal()
|
boolean |
iterate()
Delivers a message to the 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. |
void |
rollback()
|
protected void |
sendPullCommand(long timeout)
If we have a zero prefetch specified then send a pull command to the broker to pull a message we are about to receive |
void |
setAvailableListener(MessageAvailableListener availableListener)
Sets the listener used to notify synchronous consumers that there is a message available so that the MessageConsumer.receiveNoWait() can
be called. |
void |
setFailureError(IOException failureError)
|
void |
setMessageListener(javax.jms.MessageListener listener)
Sets the message consumer's MessageListener. |
protected void |
setOptimizeAcknowledge(boolean value)
|
void |
setOptimizedAckScheduledAckInterval(long optimizedAckScheduledAckInterval)
|
protected void |
setPrefetchSize(int prefetch)
|
void |
setRedeliveryPolicy(RedeliveryPolicy redeliveryPolicy)
Sets the redelivery policy used when messages are redelivered |
void |
setTransformer(MessageTransformer transformer)
Sets the transformer used to transform messages before they are sent on to the JMS bus |
void |
start()
|
void |
stop()
|
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected final ActiveMQSession session
protected final ConsumerInfo info
protected final MessageDispatchChannel unconsumedMessages
protected final LinkedList<MessageDispatch> deliveredMessages
| Constructor Detail |
|---|
public ActiveMQMessageConsumer(ActiveMQSession session,
ConsumerId consumerId,
ActiveMQDestination dest,
String name,
String selector,
int prefetch,
int maximumPendingMessageCount,
boolean noLocal,
boolean browser,
boolean dispatchAsync,
javax.jms.MessageListener messageListener)
throws javax.jms.JMSException
session - dest - name - selector - prefetch - maximumPendingMessageCount - noLocal - browser - dispatchAsync - messageListener -
javax.jms.JMSException| Method Detail |
|---|
public StatsImpl getStats()
getStats in interface StatsCapablepublic JMSConsumerStatsImpl getConsumerStats()
public RedeliveryPolicy getRedeliveryPolicy()
public void setRedeliveryPolicy(RedeliveryPolicy redeliveryPolicy)
public MessageTransformer getTransformer()
public void setTransformer(MessageTransformer transformer)
public ConsumerId getConsumerId()
public String getConsumerName()
protected boolean isNoLocal()
protected boolean isBrowser()
protected ActiveMQDestination getDestination()
public int getPrefetchNumber()
public boolean isDurableSubscriber()
public String getMessageSelector()
throws javax.jms.JMSException
getMessageSelector in interface javax.jms.MessageConsumerjavax.jms.JMSException - if the JMS provider fails to receive the next
message due to some internal error.
public javax.jms.MessageListener getMessageListener()
throws javax.jms.JMSException
MessageListener.
getMessageListener in interface javax.jms.MessageConsumerjavax.jms.JMSException - if the JMS provider fails to get the message
listener due to some internal error.MessageConsumer.setMessageListener(javax.jms.MessageListener)
public void setMessageListener(javax.jms.MessageListener listener)
throws javax.jms.JMSException
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.
setMessageListener in interface javax.jms.MessageConsumerlistener - the listener to which the messages are to be delivered
javax.jms.JMSException - if the JMS provider fails to receive the next
message due to some internal error.MessageConsumer.getMessageListener()public MessageAvailableListener getAvailableListener()
MessageAvailableConsumerMessageConsumer.receiveNoWait() can be called.
getAvailableListener in interface MessageAvailableConsumerpublic void setAvailableListener(MessageAvailableListener availableListener)
MessageConsumer.receiveNoWait() can
be called.
setAvailableListener in interface MessageAvailableConsumer
public javax.jms.Message receive()
throws javax.jms.JMSException
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.
receive in interface javax.jms.MessageConsumerjavax.jms.JMSException
public javax.jms.Message receive(long timeout)
throws javax.jms.JMSException
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.
receive in interface javax.jms.MessageConsumertimeout - the timeout value (in milliseconds), a time out of zero
never expires.
javax.jms.JMSException
public javax.jms.Message receiveNoWait()
throws javax.jms.JMSException
receiveNoWait in interface javax.jms.MessageConsumerjavax.jms.JMSException - if the JMS provider fails to receive the next
message due to some internal error.
public void close()
throws javax.jms.JMSException
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 consumer receive
call returns null when this message consumer is closed.
close in interface javax.jms.MessageConsumerjavax.jms.JMSException - if the JMS provider fails to close the consumer due
to some internal error.
public void dispose()
throws javax.jms.JMSException
javax.jms.JMSException
protected void checkClosed()
throws javax.jms.IllegalStateException
javax.jms.IllegalStateException
protected void sendPullCommand(long timeout)
throws javax.jms.JMSException
javax.jms.JMSException
protected void checkMessageListener()
throws javax.jms.JMSException
javax.jms.JMSExceptionprotected void setOptimizeAcknowledge(boolean value)
protected void setPrefetchSize(int prefetch)
public void acknowledge()
throws javax.jms.JMSException
javax.jms.JMSException
public void commit()
throws javax.jms.JMSException
javax.jms.JMSException
public void rollback()
throws javax.jms.JMSException
javax.jms.JMSExceptionpublic void dispatch(MessageDispatch md)
dispatch in interface ActiveMQDispatcherpublic int getMessageSize()
public void start()
throws javax.jms.JMSException
javax.jms.JMSExceptionpublic void stop()
public String toString()
toString in class Objectpublic boolean iterate()
javax.jms.JMSExceptionpublic boolean isInUse(ActiveMQTempDestination destination)
public long getLastDeliveredSequenceId()
public IOException getFailureError()
public void setFailureError(IOException failureError)
public long getOptimizedAckScheduledAckInterval()
public void setOptimizedAckScheduledAckInterval(long optimizedAckScheduledAckInterval)
throws javax.jms.JMSException
optimizedAckScheduledAckInterval - the optimizedAckScheduledAckInterval to set
javax.jms.JMSExceptionpublic boolean hasMessageListener()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||