org.activemq.service.impl
Class SubscriptionImpl

java.lang.Object
  extended by org.activemq.service.impl.SubscriptionImpl
All Implemented Interfaces:
Subscription
Direct Known Subclasses:
DurableTopicSubscription

public class SubscriptionImpl
extends Object
implements Subscription

A Subscription holds messages to be dispatched to a a Client Consumer

Version:
$Revision: 1.1.1.1 $

Field Summary
protected  String brokerName
           
protected  String clusterName
           
protected  Dispatcher dispatch
           
protected  MessageIdentity lastMessageIdentity
           
protected  QueueList messagePtrs
           
protected  SynchronizedInt unconsumedMessagesDispatched
           
 
Constructor Summary
SubscriptionImpl(Dispatcher dispatcher, BrokerClient client, ConsumerInfo info, Filter filter, RedeliveryPolicy redeliveryPolicy, DeadLetterPolicy deadLetterPolicy)
          Create a Subscription object that holds messages to be dispatched to a Consumer
 
Method Summary
 void addMessage(MessageContainer container, ActiveMQMessage message)
          If the Subscription is a target for the message, the subscription will add a reference to the message and register an interest in the message to the container
 void clear()
          Called when the Subscription is discarded
protected  boolean clientIDsEqual(ActiveMQMessage message)
           
protected  SubscriberEntry createSubscriptionEntry()
           
protected static boolean equal(Object left, Object right)
           
 BrokerClient getActiveClient()
           
 String getClientId()
           
 String getConsumerId()
           
 int getConsumerNumber()
           
 ActiveMQDestination getDestination()
           
 Filter getFilter()
           
 MessageIdentity getLastMessageIdentity()
          Retreives the messageIdentity of the last message sent to this Queue based Subscription
 ActiveMQMessage[] getMessagesToDispatch()
          Retrieve messages to dispatch
protected  ActiveMQMessage[] getMessagesWithPrefetch()
           
 String getPersistentKey()
          Returns the persistent key used to uniquely identify this durable topic subscription
 RedeliveryPolicy getRedeliveryPolicy()
           
 String getSelector()
           
 String getSubscriberName()
           
 SubscriberEntry getSubscriptionEntry()
          Lazily creates the persistent entry representation of this subscription
 boolean isActive()
           
 boolean isAtPrefetchLimit()
          Indicates the Subscription it's reached it's pre-fetch limit
protected  boolean isAuthorizedForMessage(ActiveMQMessage message)
          Returns whether or not the consumer can receive the given message
 boolean isBrowser()
          Indicates the consumer is a browser only
 boolean isDurableTopic()
          Indicates the Subscriber is a Durable Subscriber
 boolean isLocalSubscription()
           
 boolean isNoLocal()
           
 boolean isReadyToDispatch()
          Indicates if this Subscription has more messages to send to the Consumer
 boolean isSameDurableSubscription(ConsumerInfo info)
          Checks if this subscription is a duplicate durable subscription of the given consumer info
 boolean isTarget(ActiveMQMessage message)
          determines if the Subscription is interested in the message
 boolean isWildcard()
           
 void messageConsumed(MessageAck ack)
          Indicates a message has been delivered to a MessageConsumer
 void reset()
          Called when an active subscriber has closed.
 void setActive(boolean newActive)
          set the state of the Subscription
 void setActiveConsumer(BrokerClient client, ConsumerInfo info)
          Set the active consumer info
 void setClientId(String clientId)
           
 void setFilter(Filter filter)
           
 void setLastMessageIdentifier(MessageIdentity messageIdentity)
          Used for a Queue based Subscription to set the last acknowledged message ID
 void setNoLocal(boolean noLocal)
           
 void setRedeliveryPolicy(RedeliveryPolicy redeliveryPolicy)
           
 void setSubscriberName(String subscriberName)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dispatch

protected Dispatcher dispatch

brokerName

protected String brokerName

clusterName

protected String clusterName

lastMessageIdentity

protected MessageIdentity lastMessageIdentity

unconsumedMessagesDispatched

protected SynchronizedInt unconsumedMessagesDispatched

messagePtrs

protected QueueList messagePtrs
Constructor Detail

SubscriptionImpl

public SubscriptionImpl(Dispatcher dispatcher,
                        BrokerClient client,
                        ConsumerInfo info,
                        Filter filter,
                        RedeliveryPolicy redeliveryPolicy,
                        DeadLetterPolicy deadLetterPolicy)
Create a Subscription object that holds messages to be dispatched to a Consumer

Parameters:
dispatcher -
client -
info -
filter -
redeliveryPolicy -
deadLetterPolicy -
Method Detail

setActiveConsumer

public void setActiveConsumer(BrokerClient client,
                              ConsumerInfo info)
Set the active consumer info

Specified by:
setActiveConsumer in interface Subscription
Parameters:
client -
info -

toString

public String toString()
Overrides:
toString in class Object
Returns:
pretty print of the Subscription

clear

public void clear()
           throws JMSException
Called when the Subscription is discarded

Specified by:
clear in interface Subscription
Throws:
JMSException

reset

public void reset()
           throws JMSException
Called when an active subscriber has closed. This resets all MessagePtrs

Specified by:
reset in interface Subscription
Throws:
JMSException

getActiveClient

public BrokerClient getActiveClient()

getClientId

public String getClientId()
Specified by:
getClientId in interface Subscription
Returns:
Returns the clientId.

setClientId

public void setClientId(String clientId)
Parameters:
clientId - The clientId to set.

getFilter

public Filter getFilter()
Returns:
Returns the filter.

setFilter

public void setFilter(Filter filter)
Parameters:
filter - The filter to set.

isWildcard

public boolean isWildcard()
Specified by:
isWildcard in interface Subscription

getPersistentKey

public String getPersistentKey()
Description copied from interface: Subscription
Returns the persistent key used to uniquely identify this durable topic subscription

Specified by:
getPersistentKey in interface Subscription
Returns:

isSameDurableSubscription

public boolean isSameDurableSubscription(ConsumerInfo info)
                                  throws JMSException
Description copied from interface: Subscription
Checks if this subscription is a duplicate durable subscription of the given consumer info

Specified by:
isSameDurableSubscription in interface Subscription
Returns:
true if this subscription is a durable topic subscription and the clientID and consumer names match
Throws:
JMSException

isNoLocal

public boolean isNoLocal()
Returns:
Returns the noLocal.

setNoLocal

public void setNoLocal(boolean noLocal)
Parameters:
noLocal - The noLocal to set.

getSubscriberName

public String getSubscriberName()
Specified by:
getSubscriberName in interface Subscription
Returns:
Returns the subscriberName.

setSubscriberName

public void setSubscriberName(String subscriberName)
Parameters:
subscriberName - The subscriberName to set.

getRedeliveryPolicy

public RedeliveryPolicy getRedeliveryPolicy()

setRedeliveryPolicy

public void setRedeliveryPolicy(RedeliveryPolicy redeliveryPolicy)

isTarget

public boolean isTarget(ActiveMQMessage message)
                 throws JMSException
determines if the Subscription is interested in the message

Specified by:
isTarget in interface Subscription
Parameters:
message -
Returns:
true if this Subscription will accept the message
Throws:
JMSException

addMessage

public void addMessage(MessageContainer container,
                       ActiveMQMessage message)
                throws JMSException
If the Subscription is a target for the message, the subscription will add a reference to the message and register an interest in the message to the container

Specified by:
addMessage in interface Subscription
Parameters:
container -
message -
Throws:
JMSException

messageConsumed

public void messageConsumed(MessageAck ack)
                     throws JMSException
Indicates a message has been delivered to a MessageConsumer

Specified by:
messageConsumed in interface Subscription
Parameters:
ack -
Throws:
JMSException

getMessagesToDispatch

public ActiveMQMessage[] getMessagesToDispatch()
                                        throws JMSException
Retrieve messages to dispatch

Specified by:
getMessagesToDispatch in interface Subscription
Returns:
the messages to dispatch
Throws:
JMSException

getSubscriptionEntry

public SubscriberEntry getSubscriptionEntry()
Description copied from interface: Subscription
Lazily creates the persistent entry representation of this subscription

Specified by:
getSubscriptionEntry in interface Subscription

isLocalSubscription

public boolean isLocalSubscription()
Specified by:
isLocalSubscription in interface Subscription

createSubscriptionEntry

protected SubscriberEntry createSubscriptionEntry()

getMessagesWithPrefetch

protected ActiveMQMessage[] getMessagesWithPrefetch()
                                             throws JMSException
Throws:
JMSException

isAtPrefetchLimit

public boolean isAtPrefetchLimit()
                          throws JMSException
Indicates the Subscription it's reached it's pre-fetch limit

Specified by:
isAtPrefetchLimit in interface Subscription
Returns:
true/false
Throws:
JMSException

isReadyToDispatch

public boolean isReadyToDispatch()
                          throws JMSException
Indicates if this Subscription has more messages to send to the Consumer

Specified by:
isReadyToDispatch in interface Subscription
Returns:
true if more messages available to dispatch
Throws:
JMSException

getDestination

public ActiveMQDestination getDestination()
Specified by:
getDestination in interface Subscription
Returns:
Returns the destination.

getSelector

public String getSelector()
Specified by:
getSelector in interface Subscription
Returns:
Returns the selector.

isActive

public boolean isActive()
Specified by:
isActive in interface Subscription
Returns:
Returns the active.

setActive

public void setActive(boolean newActive)
               throws JMSException
Description copied from interface: Subscription
set the state of the Subscription

Specified by:
setActive in interface Subscription
Parameters:
newActive - The active to set.
Throws:
JMSException

getConsumerNumber

public int getConsumerNumber()
Specified by:
getConsumerNumber in interface Subscription
Returns:
Returns the consumerNumber.

getConsumerId

public String getConsumerId()
Specified by:
getConsumerId in interface Subscription
Returns:
the consumer Id for the active consumer

isDurableTopic

public boolean isDurableTopic()
                       throws JMSException
Indicates the Subscriber is a Durable Subscriber

Specified by:
isDurableTopic in interface Subscription
Returns:
true if the subscriber is a durable topic
Throws:
JMSException

isBrowser

public boolean isBrowser()
                  throws JMSException
Indicates the consumer is a browser only

Specified by:
isBrowser in interface Subscription
Returns:
true if a Browser
Throws:
JMSException

getLastMessageIdentity

public MessageIdentity getLastMessageIdentity()
                                       throws JMSException
Description copied from interface: Subscription
Retreives the messageIdentity of the last message sent to this Queue based Subscription

Specified by:
getLastMessageIdentity in interface Subscription
Returns:
the messageId of the last message or null
Throws:
JMSException

setLastMessageIdentifier

public void setLastMessageIdentifier(MessageIdentity messageIdentity)
                              throws JMSException
Description copied from interface: Subscription
Used for a Queue based Subscription to set the last acknowledged message ID

Specified by:
setLastMessageIdentifier in interface Subscription
Throws:
JMSException

clientIDsEqual

protected boolean clientIDsEqual(ActiveMQMessage message)

equal

protected static final boolean equal(Object left,
                                     Object right)

isAuthorizedForMessage

protected boolean isAuthorizedForMessage(ActiveMQMessage message)
Returns whether or not the consumer can receive the given message



Copyright © 2004-2008 Protique, Ltd.. All Rights Reserved.