org.apache.activemq.broker.region
Class Topic

java.lang.Object
  extended by org.apache.activemq.broker.region.Topic
All Implemented Interfaces:
Destination, Service

public class Topic
extends java.lang.Object
implements Destination

The Topic is a destination that sends a copy of a message to every active Subscription registered.

Version:
$Revision: 1.21 $

Field Summary
protected  edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArrayList consumers
           
protected  ActiveMQDestination destination
           
protected  DestinationStatistics destinationStatistics
           
protected  Valve dispatchValve
           
protected  TopicMessageStore store
           
protected  UsageManager usageManager
           
 
Constructor Summary
Topic(ActiveMQDestination destination, TopicMessageStore store, UsageManager memoryManager, DestinationStatistics parentStats, TaskRunnerFactory taskFactory)
           
 
Method Summary
 void acknowledge(ConnectionContext context, Subscription sub, MessageAck ack, MessageReference node)
           
 void activate(ConnectionContext context, DurableTopicSubscription subscription)
           
 void addSubscription(ConnectionContext context, Subscription sub)
           
 Message[] browse()
           
 void deactivate(ConnectionContext context, DurableTopicSubscription sub)
           
 void deleteSubscription(ConnectionContext context, SubscriptionKey key)
           
protected  void dispatch(ConnectionContext context, Message message)
           
 void dispose(ConnectionContext context)
           
 void gc()
           
 ActiveMQDestination getActiveMQDestination()
           
 DeadLetterStrategy getDeadLetterStrategy()
           
 java.lang.String getDestination()
           
 DestinationStatistics getDestinationStatistics()
           
 DispatchPolicy getDispatchPolicy()
           
 MessageStore getMessageStore()
           
 java.lang.String getName()
           
 SubscriptionRecoveryPolicy getSubscriptionRecoveryPolicy()
           
 UsageManager getUsageManager()
           
 boolean isSendAdvisoryIfNoConsumers()
           
 Message loadMessage(MessageId messageId)
           
 boolean lock(MessageReference node, LockOwner sub)
           
protected  void onMessageWithNoConsumers(ConnectionContext context, Message message)
          Provides a hook to allow messages with no consumer to be processed in some way - such as to send to a dead letter queue or something..
 void removeSubscription(ConnectionContext context, Subscription sub)
           
 void send(ConnectionContext context, Message message)
           
 void setDeadLetterStrategy(DeadLetterStrategy deadLetterStrategy)
           
 void setDispatchPolicy(DispatchPolicy dispatchPolicy)
           
 void setSendAdvisoryIfNoConsumers(boolean sendAdvisoryIfNoConsumers)
           
 void setSubscriptionRecoveryPolicy(SubscriptionRecoveryPolicy subscriptionRecoveryPolicy)
           
 void start()
           
 void stop()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

destination

protected final ActiveMQDestination destination

consumers

protected final edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArrayList consumers

dispatchValve

protected final Valve dispatchValve

store

protected final TopicMessageStore store

usageManager

protected final UsageManager usageManager

destinationStatistics

protected final DestinationStatistics destinationStatistics
Constructor Detail

Topic

public Topic(ActiveMQDestination destination,
             TopicMessageStore store,
             UsageManager memoryManager,
             DestinationStatistics parentStats,
             TaskRunnerFactory taskFactory)
Method Detail

lock

public boolean lock(MessageReference node,
                    LockOwner sub)
Specified by:
lock in interface Destination

addSubscription

public void addSubscription(ConnectionContext context,
                            Subscription sub)
                     throws java.lang.Exception
Specified by:
addSubscription in interface Destination
Throws:
java.lang.Exception

removeSubscription

public void removeSubscription(ConnectionContext context,
                               Subscription sub)
                        throws java.lang.Exception
Specified by:
removeSubscription in interface Destination
Throws:
java.lang.Exception

deleteSubscription

public void deleteSubscription(ConnectionContext context,
                               SubscriptionKey key)
                        throws java.io.IOException
Throws:
java.io.IOException

activate

public void activate(ConnectionContext context,
                     DurableTopicSubscription subscription)
              throws java.lang.Exception
Throws:
java.lang.Exception

deactivate

public void deactivate(ConnectionContext context,
                       DurableTopicSubscription sub)
                throws java.lang.Exception
Throws:
java.lang.Exception

send

public void send(ConnectionContext context,
                 Message message)
          throws java.lang.Exception
Specified by:
send in interface Destination
Throws:
java.lang.Exception

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

acknowledge

public void acknowledge(ConnectionContext context,
                        Subscription sub,
                        MessageAck ack,
                        MessageReference node)
                 throws java.io.IOException
Specified by:
acknowledge in interface Destination
Throws:
java.io.IOException

dispose

public void dispose(ConnectionContext context)
             throws java.io.IOException
Specified by:
dispose in interface Destination
Throws:
java.io.IOException

gc

public void gc()
Specified by:
gc in interface Destination

loadMessage

public Message loadMessage(MessageId messageId)
                    throws java.io.IOException
Throws:
java.io.IOException

start

public void start()
           throws java.lang.Exception
Specified by:
start in interface Service
Throws:
java.lang.Exception

stop

public void stop()
          throws java.lang.Exception
Specified by:
stop in interface Service
Throws:
java.lang.Exception

browse

public Message[] browse()
Specified by:
browse in interface Destination

getUsageManager

public UsageManager getUsageManager()
Specified by:
getUsageManager in interface Destination

getDestinationStatistics

public DestinationStatistics getDestinationStatistics()
Specified by:
getDestinationStatistics in interface Destination

getActiveMQDestination

public ActiveMQDestination getActiveMQDestination()
Specified by:
getActiveMQDestination in interface Destination

getDestination

public java.lang.String getDestination()

getDispatchPolicy

public DispatchPolicy getDispatchPolicy()

setDispatchPolicy

public void setDispatchPolicy(DispatchPolicy dispatchPolicy)

getSubscriptionRecoveryPolicy

public SubscriptionRecoveryPolicy getSubscriptionRecoveryPolicy()

setSubscriptionRecoveryPolicy

public void setSubscriptionRecoveryPolicy(SubscriptionRecoveryPolicy subscriptionRecoveryPolicy)

isSendAdvisoryIfNoConsumers

public boolean isSendAdvisoryIfNoConsumers()

setSendAdvisoryIfNoConsumers

public void setSendAdvisoryIfNoConsumers(boolean sendAdvisoryIfNoConsumers)

getMessageStore

public MessageStore getMessageStore()

getDeadLetterStrategy

public DeadLetterStrategy getDeadLetterStrategy()
Specified by:
getDeadLetterStrategy in interface Destination

setDeadLetterStrategy

public void setDeadLetterStrategy(DeadLetterStrategy deadLetterStrategy)

getName

public java.lang.String getName()
Specified by:
getName in interface Destination

dispatch

protected void dispatch(ConnectionContext context,
                        Message message)
                 throws java.lang.Exception
Throws:
java.lang.Exception

onMessageWithNoConsumers

protected void onMessageWithNoConsumers(ConnectionContext context,
                                        Message message)
                                 throws java.lang.Exception
Provides a hook to allow messages with no consumer to be processed in some way - such as to send to a dead letter queue or something..

Throws:
java.lang.Exception


Copyright © 2010 Apache Software Foundation. All Rights Reserved.