org.apache.activemq.broker.region
Interface Subscription

All Superinterfaces:
SubscriptionRecovery
All Known Implementing Classes:
AbstractSubscription, DurableTopicSubscription, PrefetchSubscription, QueueBrowserSubscription, QueueSubscription, TopicSubscription

public interface Subscription
extends SubscriptionRecovery


Method Summary
 void acknowledge(ConnectionContext context, MessageAck ack)
          Used when client acknowledge receipt of dispatched message.
 void add(ConnectionContext context, Destination destination)
          The subscription will be receiving messages from the destination.
 void add(MessageReference node)
          Used to add messages that match the subscription.
 int countBeforeFull()
           
 void destroy()
          Called when the subscription is destroyed.
 void gc()
          The subscription should release as may references as it can to help the garbage collector reclaim memory.
 ConsumerInfo getConsumerInfo()
          The ConsumerInfo object that created the subscription.
 ConnectionContext getContext()
           
 int getCursorMemoryHighWaterMark()
           
 long getDequeueCounter()
           
 long getDispatchedCounter()
           
 int getDispatchedQueueSize()
           
 long getEnqueueCounter()
           
 int getInFlightSize()
           
 int getInFlightUsage()
           
 ObjectName getObjectName()
           
 int getPendingQueueSize()
           
 int getPrefetchSize()
           
 String getSelector()
           
 long getTimeOfLastMessageAck()
          Returns the time since the last Ack message was received by this subscription.
 boolean isBrowser()
           
 boolean isFull()
           
 boolean isHighWaterMark()
           
 boolean isLowWaterMark()
           
 boolean isRecoveryRequired()
          Informs the Broker if the subscription needs to intervention to recover it's state e.g.
 boolean isSlowConsumer()
           
 boolean matches(ActiveMQDestination destination)
          Is the subscription interested in messages in the destination?
 boolean matches(MessageReference node, MessageEvaluationContext context)
          Is the subscription interested in the message?
 void processMessageDispatchNotification(MessageDispatchNotification mdn)
          Used by a Slave Broker to update dispatch infomation
 Response pullMessage(ConnectionContext context, MessagePull pull)
          Allows a consumer to pull a message on demand
 List<MessageReference> remove(ConnectionContext context, Destination destination)
          The subscription will be no longer be receiving messages from the destination.
 void setCursorMemoryHighWaterMark(int cursorMemoryHighWaterMark)
           
 void setObjectName(ObjectName objectName)
          Set when the subscription is registered in JMX
 void setSelector(String selector)
          Attempts to change the current active selector on the subscription.
 void unmatched(MessageReference node)
           
 void updateConsumerPrefetch(int newPrefetch)
          inform the MessageConsumer on the client to change it's prefetch
 
Methods inherited from interface org.apache.activemq.broker.region.SubscriptionRecovery
addRecoveredMessage, getActiveMQDestination
 

Method Detail

add

void add(MessageReference node)
         throws Exception
Used to add messages that match the subscription.

Parameters:
node -
Throws:
Exception
InterruptedException
IOException

acknowledge

void acknowledge(ConnectionContext context,
                 MessageAck ack)
                 throws Exception
Used when client acknowledge receipt of dispatched message.

Parameters:
node -
Throws:
IOException
Exception

pullMessage

Response pullMessage(ConnectionContext context,
                     MessagePull pull)
                     throws Exception
Allows a consumer to pull a message on demand

Throws:
Exception

matches

boolean matches(MessageReference node,
                MessageEvaluationContext context)
                throws IOException
Is the subscription interested in the message?

Parameters:
node -
context -
Returns:
Throws:
IOException

matches

boolean matches(ActiveMQDestination destination)
Is the subscription interested in messages in the destination?

Parameters:
context -
Returns:

add

void add(ConnectionContext context,
         Destination destination)
         throws Exception
The subscription will be receiving messages from the destination.

Parameters:
context -
destination -
Throws:
Exception

remove

List<MessageReference> remove(ConnectionContext context,
                              Destination destination)
                              throws Exception
The subscription will be no longer be receiving messages from the destination.

Parameters:
context -
destination -
Returns:
a list of un-acked messages that were added to the subscription.
Throws:
Exception

getConsumerInfo

ConsumerInfo getConsumerInfo()
The ConsumerInfo object that created the subscription.

Parameters:
destination -

gc

void gc()
The subscription should release as may references as it can to help the garbage collector reclaim memory.


processMessageDispatchNotification

void processMessageDispatchNotification(MessageDispatchNotification mdn)
                                        throws Exception
Used by a Slave Broker to update dispatch infomation

Parameters:
mdn -
Throws:
Exception

getPendingQueueSize

int getPendingQueueSize()
Returns:
number of messages pending delivery

getDispatchedQueueSize

int getDispatchedQueueSize()
Returns:
number of messages dispatched to the client

getDispatchedCounter

long getDispatchedCounter()
Returns:
number of messages dispatched to the client

getEnqueueCounter

long getEnqueueCounter()
Returns:
number of messages that matched the subscription

getDequeueCounter

long getDequeueCounter()
Returns:
number of messages queued by the client

getSelector

String getSelector()
Returns:
the JMS selector on the current subscription

setSelector

void setSelector(String selector)
                 throws InvalidSelectorException,
                        UnsupportedOperationException
Attempts to change the current active selector on the subscription. This operation is not supported for persistent topics.

Throws:
InvalidSelectorException
UnsupportedOperationException

getObjectName

ObjectName getObjectName()
Returns:
the JMX object name that this subscription was registered as if applicable

setObjectName

void setObjectName(ObjectName objectName)
Set when the subscription is registered in JMX


isLowWaterMark

boolean isLowWaterMark()
Returns:
true when 60% or more room is left for dispatching messages

isHighWaterMark

boolean isHighWaterMark()
Returns:
true when 10% or less room is left for dispatching messages

isFull

boolean isFull()
Returns:
true if there is no space to dispatch messages

updateConsumerPrefetch

void updateConsumerPrefetch(int newPrefetch)
inform the MessageConsumer on the client to change it's prefetch

Parameters:
newPrefetch -

destroy

void destroy()
Called when the subscription is destroyed.


getPrefetchSize

int getPrefetchSize()
Returns:
the prefetch size that is configured for the subscription

getInFlightSize

int getInFlightSize()
Returns:
the number of messages awaiting acknowledgement

getInFlightUsage

int getInFlightUsage()
Returns:
the in flight messages as a percentage of the prefetch size

isRecoveryRequired

boolean isRecoveryRequired()
Informs the Broker if the subscription needs to intervention to recover it's state e.g. DurableTopicSubscriber may do

Returns:
true if recovery required
See Also:
org.apache.activemq.region.cursors.PendingMessageCursor

isBrowser

boolean isBrowser()
Returns:
true if a browser

countBeforeFull

int countBeforeFull()
Returns:
the number of messages this subscription can accept before its full

getContext

ConnectionContext getContext()

getCursorMemoryHighWaterMark

int getCursorMemoryHighWaterMark()

setCursorMemoryHighWaterMark

void setCursorMemoryHighWaterMark(int cursorMemoryHighWaterMark)

isSlowConsumer

boolean isSlowConsumer()

unmatched

void unmatched(MessageReference node)
               throws IOException
Throws:
IOException

getTimeOfLastMessageAck

long getTimeOfLastMessageAck()
Returns the time since the last Ack message was received by this subscription. If there has never been an ack this value should be set to the creation time of the subscription.

Returns:
time of last received Ack message or Subscription create time if no Acks.


Copyright © 2005–2013 The Apache Software Foundation. All rights reserved.