org.apache.activemq.broker.region
Class AbstractRegion

java.lang.Object
  extended by org.apache.activemq.broker.region.AbstractRegion
All Implemented Interfaces:
Region, Service
Direct Known Subclasses:
AbstractTempRegion, QueueRegion, TopicRegion

public abstract class AbstractRegion
extends java.lang.Object
implements Region


Field Summary
protected  boolean autoCreateDestinations
           
protected  RegionBroker broker
           
protected  java.util.Map<ConsumerId,java.lang.Object> consumerChangeMutexMap
           
protected  DestinationFactory destinationFactory
           
protected  DestinationMap destinationMap
           
protected  java.util.Map<ActiveMQDestination,Destination> destinations
           
protected  java.lang.Object destinationsMutex
           
protected  DestinationStatistics destinationStatistics
           
protected  boolean started
           
protected  java.util.Map<ConsumerId,Subscription> subscriptions
           
protected  TaskRunnerFactory taskRunnerFactory
           
protected  SystemUsage usageManager
           
 
Constructor Summary
AbstractRegion(RegionBroker broker, DestinationStatistics destinationStatistics, SystemUsage memoryManager, TaskRunnerFactory taskRunnerFactory, DestinationFactory destinationFactory)
           
 
Method Summary
 void acknowledge(ConsumerBrokerExchange consumerExchange, MessageAck ack)
          Used to acknowledge the receipt of a message by a client.
 Subscription addConsumer(ConnectionContext context, ConsumerInfo info)
          Adds a consumer.
 Destination addDestination(ConnectionContext context, ActiveMQDestination destination, boolean createIfTemporary)
          Used to create a destination.
 void addProducer(ConnectionContext context, ProducerInfo info)
          Adds a Producer.
protected  java.util.List<Subscription> addSubscriptionsForDestination(ConnectionContext context, Destination dest)
           
protected  Destination createDestination(ConnectionContext context, ActiveMQDestination destination)
           
protected abstract  Subscription createSubscription(ConnectionContext context, ConsumerInfo info)
           
protected  void destroySubscription(Subscription sub)
           
protected  void dispose(ConnectionContext context, Destination dest)
           
 void gc()
           
 java.util.Map<ActiveMQDestination,Destination> getDestinationMap()
          Returns a copy of the current destinations available in the region
 java.util.Set<Destination> getDestinations(ActiveMQDestination destination)
          Provide an exact or wildcard lookup of destinations in the region
 java.util.Set getDurableDestinations()
          Get all the Destinations that are in storage
protected  java.util.Set<ActiveMQDestination> getInactiveDestinations()
           
 java.util.Map<ConsumerId,Subscription> getSubscriptions()
           
 boolean isAutoCreateDestinations()
           
protected  Destination lookup(ConnectionContext context, ActiveMQDestination destination, boolean createTemporary)
           
 Response messagePull(ConnectionContext context, MessagePull pull)
          Allows a consumer to pull a message from a queue
 void processConsumerControl(ConsumerBrokerExchange consumerExchange, ConsumerControl control)
           
 void processDispatchNotification(MessageDispatchNotification messageDispatchNotification)
          Process a notification of a dispatch - used by a Slave Broker
protected  void processDispatchNotificationViaDestination(MessageDispatchNotification messageDispatchNotification)
           
 void removeConsumer(ConnectionContext context, ConsumerInfo info)
          Removes a consumer.
 void removeDestination(ConnectionContext context, ActiveMQDestination destination, long timeout)
          Used to destroy a destination.
 void removeProducer(ConnectionContext context, ProducerInfo info)
          Removes a Producer.
 void removeSubscription(ConnectionContext context, RemoveSubscriptionInfo info)
          Deletes a durable subscription.
 void send(ProducerBrokerExchange producerExchange, Message messageSend)
          Send a message to the broker to using the specified destination.
 void setAutoCreateDestinations(boolean autoCreateDestinations)
           
 void start()
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

destinations

protected final java.util.Map<ActiveMQDestination,Destination> destinations

destinationMap

protected final DestinationMap destinationMap

subscriptions

protected final java.util.Map<ConsumerId,Subscription> subscriptions

usageManager

protected final SystemUsage usageManager

destinationFactory

protected final DestinationFactory destinationFactory

destinationStatistics

protected final DestinationStatistics destinationStatistics

broker

protected final RegionBroker broker

autoCreateDestinations

protected boolean autoCreateDestinations

taskRunnerFactory

protected final TaskRunnerFactory taskRunnerFactory

destinationsMutex

protected final java.lang.Object destinationsMutex

consumerChangeMutexMap

protected final java.util.Map<ConsumerId,java.lang.Object> consumerChangeMutexMap

started

protected boolean started
Constructor Detail

AbstractRegion

public AbstractRegion(RegionBroker broker,
                      DestinationStatistics destinationStatistics,
                      SystemUsage memoryManager,
                      TaskRunnerFactory taskRunnerFactory,
                      DestinationFactory destinationFactory)
Method Detail

start

public final 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

addDestination

public Destination addDestination(ConnectionContext context,
                                  ActiveMQDestination destination,
                                  boolean createIfTemporary)
                           throws java.lang.Exception
Description copied from interface: Region
Used to create a destination. Usually, this method is invoked as a side-effect of sending a message to a destination that does not exist yet.

Specified by:
addDestination in interface Region
destination - the destination to create.
Returns:
TODO
Throws:
java.lang.Exception - TODO

getSubscriptions

public java.util.Map<ConsumerId,Subscription> getSubscriptions()

addSubscriptionsForDestination

protected java.util.List<Subscription> addSubscriptionsForDestination(ConnectionContext context,
                                                                      Destination dest)
                                                               throws java.lang.Exception
Throws:
java.lang.Exception

removeDestination

public void removeDestination(ConnectionContext context,
                              ActiveMQDestination destination,
                              long timeout)
                       throws java.lang.Exception
Description copied from interface: Region
Used to destroy a destination. This should try to quiesce use of the destination up to the timeout allotted time before removing the destination. This will remove all persistent messages associated with the destination.

Specified by:
removeDestination in interface Region
Parameters:
context - the environment the operation is being executed under.
destination - what is being removed from the broker.
timeout - the max amount of time to wait for the destination to quiesce
Throws:
java.lang.Exception - TODO

getDestinations

public java.util.Set<Destination> getDestinations(ActiveMQDestination destination)
Provide an exact or wildcard lookup of destinations in the region

Specified by:
getDestinations in interface Region
Returns:
a set of matching destination objects.

getDestinationMap

public java.util.Map<ActiveMQDestination,Destination> getDestinationMap()
Description copied from interface: Region
Returns a copy of the current destinations available in the region

Specified by:
getDestinationMap in interface Region
Returns:
a copy of the regions currently active at the time of the call with the key the destination and the value the Destination.

addConsumer

public Subscription addConsumer(ConnectionContext context,
                                ConsumerInfo info)
                         throws java.lang.Exception
Description copied from interface: Region
Adds a consumer.

Specified by:
addConsumer in interface Region
Parameters:
context - the environment the operation is being executed under.
Returns:
TODO
Throws:
java.lang.Exception - TODO

getDurableDestinations

public java.util.Set getDurableDestinations()
Get all the Destinations that are in storage

Returns:
Set of all stored destinations

getInactiveDestinations

protected java.util.Set<ActiveMQDestination> getInactiveDestinations()
Returns:
all Destinations that don't have active consumers

removeConsumer

public void removeConsumer(ConnectionContext context,
                           ConsumerInfo info)
                    throws java.lang.Exception
Description copied from interface: Region
Removes a consumer.

Specified by:
removeConsumer in interface Region
Parameters:
context - the environment the operation is being executed under.
Throws:
java.lang.Exception - TODO

destroySubscription

protected void destroySubscription(Subscription sub)

removeSubscription

public void removeSubscription(ConnectionContext context,
                               RemoveSubscriptionInfo info)
                        throws java.lang.Exception
Description copied from interface: Region
Deletes a durable subscription.

Specified by:
removeSubscription in interface Region
Parameters:
context - the environment the operation is being executed under.
info - TODO
Throws:
java.lang.Exception - TODO

send

public void send(ProducerBrokerExchange producerExchange,
                 Message messageSend)
          throws java.lang.Exception
Description copied from interface: Region
Send a message to the broker to using the specified destination. The destination specified in the message does not need to match the destination the message is sent to. This is handy in case the message is being sent to a dead letter destination.

Specified by:
send in interface Region
Parameters:
producerExchange - the environment the operation is being executed under.
Throws:
java.lang.Exception - TODO

acknowledge

public void acknowledge(ConsumerBrokerExchange consumerExchange,
                        MessageAck ack)
                 throws java.lang.Exception
Description copied from interface: Region
Used to acknowledge the receipt of a message by a client.

Specified by:
acknowledge in interface Region
Parameters:
consumerExchange - the environment the operation is being executed under.
Throws:
java.lang.Exception - TODO

messagePull

public Response messagePull(ConnectionContext context,
                            MessagePull pull)
                     throws java.lang.Exception
Description copied from interface: Region
Allows a consumer to pull a message from a queue

Specified by:
messagePull in interface Region
Throws:
java.lang.Exception

lookup

protected Destination lookup(ConnectionContext context,
                             ActiveMQDestination destination,
                             boolean createTemporary)
                      throws java.lang.Exception
Throws:
java.lang.Exception

processDispatchNotification

public void processDispatchNotification(MessageDispatchNotification messageDispatchNotification)
                                 throws java.lang.Exception
Description copied from interface: Region
Process a notification of a dispatch - used by a Slave Broker

Specified by:
processDispatchNotification in interface Region
Throws:
java.lang.Exception - TODO

processDispatchNotificationViaDestination

protected void processDispatchNotificationViaDestination(MessageDispatchNotification messageDispatchNotification)
                                                  throws java.lang.Exception
Throws:
java.lang.Exception

gc

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

createSubscription

protected abstract Subscription createSubscription(ConnectionContext context,
                                                   ConsumerInfo info)
                                            throws java.lang.Exception
Throws:
java.lang.Exception

createDestination

protected Destination createDestination(ConnectionContext context,
                                        ActiveMQDestination destination)
                                 throws java.lang.Exception
Throws:
java.lang.Exception

isAutoCreateDestinations

public boolean isAutoCreateDestinations()

setAutoCreateDestinations

public void setAutoCreateDestinations(boolean autoCreateDestinations)

addProducer

public void addProducer(ConnectionContext context,
                        ProducerInfo info)
                 throws java.lang.Exception
Description copied from interface: Region
Adds a Producer.

Specified by:
addProducer in interface Region
Parameters:
context - the environment the operation is being executed under.
Throws:
java.lang.Exception - TODO

removeProducer

public void removeProducer(ConnectionContext context,
                           ProducerInfo info)
                    throws java.lang.Exception
Removes a Producer.

Specified by:
removeProducer in interface Region
Parameters:
context - the environment the operation is being executed under.
Throws:
java.lang.Exception - TODO

dispose

protected void dispose(ConnectionContext context,
                       Destination dest)
                throws java.lang.Exception
Throws:
java.lang.Exception

processConsumerControl

public void processConsumerControl(ConsumerBrokerExchange consumerExchange,
                                   ConsumerControl control)
Specified by:
processConsumerControl in interface Region


Copyright © 2005-2011 FuseSource, Corp.. All Rights Reserved.