Class AbstractRegion
- java.lang.Object
-
- org.apache.activemq.broker.region.AbstractRegion
-
- Direct Known Subclasses:
AbstractTempRegion,QueueRegion,TopicRegion
public abstract class AbstractRegion extends Object implements Region
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanautoCreateDestinationsprotected RegionBrokerbrokerprotected Map<ConsumerId,Object>consumerChangeMutexMapprotected DestinationFactorydestinationFactoryprotected DestinationMapdestinationMapprotected Map<ActiveMQDestination,Destination>destinationsprotected ReentrantReadWriteLockdestinationsLockprotected DestinationStatisticsdestinationStatisticsprotected RegionStatisticsregionStatisticsprotected booleanstartedprotected Map<ConsumerId,Subscription>subscriptionsprotected TaskRunnerFactorytaskRunnerFactoryprotected SystemUsageusageManager
-
Constructor Summary
Constructors Constructor Description AbstractRegion(RegionBroker broker, DestinationStatistics destinationStatistics, SystemUsage memoryManager, TaskRunnerFactory taskRunnerFactory, DestinationFactory destinationFactory)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidacknowledge(ConsumerBrokerExchange consumerExchange, MessageAck ack)Used to acknowledge the receipt of a message by a client.SubscriptionaddConsumer(ConnectionContext context, ConsumerInfo info)Adds a consumer.DestinationaddDestination(ConnectionContext context, ActiveMQDestination destination, boolean createIfTemporary)Used to create a destination.voidaddProducer(ConnectionContext context, ProducerInfo info)Adds a Producer.protected List<Subscription>addSubscriptionsForDestination(ConnectionContext context, Destination dest)protected DestinationcreateDestination(ConnectionContext context, ActiveMQDestination destination)protected abstract SubscriptioncreateSubscription(ConnectionContext context, ConsumerInfo info)protected voiddestroySubscription(Subscription sub)protected voiddispose(ConnectionContext context, Destination dest)voidgc()Map<ActiveMQDestination,Destination>getDestinationMap()Returns a reference to the concurrent hash map that holds known destinations, do not modifySet<Destination>getDestinations(ActiveMQDestination destination)Provide an exact or wildcard lookup of destinations in the regionSetgetDurableDestinations()Get all the Destinations that are in storageprotected Set<ActiveMQDestination>getInactiveDestinations()Map<ConsumerId,Subscription>getSubscriptions()booleanisAutoCreateDestinations()protected Destinationlookup(ConnectionContext context, ActiveMQDestination destination, boolean createTemporary)ResponsemessagePull(ConnectionContext context, MessagePull pull)Allows a consumer to pull a message from a queuevoidprocessConsumerControl(ConsumerBrokerExchange consumerExchange, ConsumerControl control)voidprocessDispatchNotification(MessageDispatchNotification messageDispatchNotification)Process a notification of a dispatch - used by a Slave Brokerprotected voidprocessDispatchNotificationViaDestination(MessageDispatchNotification messageDispatchNotification)voidreapplyInterceptor()voidremoveConsumer(ConnectionContext context, ConsumerInfo info)Removes a consumer.voidremoveDestination(ConnectionContext context, ActiveMQDestination destination, long timeout)Used to destroy a destination.voidremoveProducer(ConnectionContext context, ProducerInfo info)Removes a Producer.voidremoveSubscription(ConnectionContext context, RemoveSubscriptionInfo info)Deletes a durable subscription.voidsend(ProducerBrokerExchange producerExchange, Message messageSend)Send a message to the broker to using the specified destination.voidsetAutoCreateDestinations(boolean autoCreateDestinations)voidstart()voidstop()protected voidupdateRegionDestCounts(ActiveMQDestination destination, int count)Updates the counts in RegionStatistics based on whether or not the destination is an Advisory Destination or notprotected voidvalidateMaxDestinations(ActiveMQDestination destination)This method checks whether or not the destination can be created based onPolicyEntry.getMaxDestinations(), if it has been set.
-
-
-
Field Detail
-
destinations
protected final Map<ActiveMQDestination,Destination> destinations
-
destinationMap
protected final DestinationMap destinationMap
-
subscriptions
protected final Map<ConsumerId,Subscription> subscriptions
-
usageManager
protected final SystemUsage usageManager
-
destinationFactory
protected final DestinationFactory destinationFactory
-
destinationStatistics
protected final DestinationStatistics destinationStatistics
-
regionStatistics
protected final RegionStatistics regionStatistics
-
broker
protected final RegionBroker broker
-
autoCreateDestinations
protected boolean autoCreateDestinations
-
taskRunnerFactory
protected final TaskRunnerFactory taskRunnerFactory
-
destinationsLock
protected final ReentrantReadWriteLock destinationsLock
-
consumerChangeMutexMap
protected final Map<ConsumerId,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 Exception
-
addDestination
public Destination addDestination(ConnectionContext context, ActiveMQDestination destination, boolean createIfTemporary) throws Exception
Description copied from interface:RegionUsed 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:
addDestinationin interfaceRegiondestination- the destination to create.- Returns:
- TODO
- Throws:
Exception- TODO
-
getSubscriptions
public Map<ConsumerId,Subscription> getSubscriptions()
-
updateRegionDestCounts
protected void updateRegionDestCounts(ActiveMQDestination destination, int count)
Updates the counts in RegionStatistics based on whether or not the destination is an Advisory Destination or not- Parameters:
destination- the destination being used to determine which counters to updatecount- the count to add to the counters
-
validateMaxDestinations
protected void validateMaxDestinations(ActiveMQDestination destination) throws Exception
This method checks whether or not the destination can be created based onPolicyEntry.getMaxDestinations(), if it has been set. Advisory topics are ignored.- Parameters:
destination-- Throws:
Exception
-
addSubscriptionsForDestination
protected List<Subscription> addSubscriptionsForDestination(ConnectionContext context, Destination dest) throws Exception
- Throws:
Exception
-
removeDestination
public void removeDestination(ConnectionContext context, ActiveMQDestination destination, long timeout) throws Exception
Description copied from interface:RegionUsed 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:
removeDestinationin interfaceRegion- 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:
Exception- TODO
-
getDestinations
public Set<Destination> getDestinations(ActiveMQDestination destination)
Provide an exact or wildcard lookup of destinations in the region- Specified by:
getDestinationsin interfaceRegion- Returns:
- a set of matching destination objects.
-
getDestinationMap
public Map<ActiveMQDestination,Destination> getDestinationMap()
Description copied from interface:RegionReturns a reference to the concurrent hash map that holds known destinations, do not modify- Specified by:
getDestinationMapin interfaceRegion
-
addConsumer
public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception
Description copied from interface:RegionAdds a consumer.- Specified by:
addConsumerin interfaceRegion- Parameters:
context- the environment the operation is being executed under.- Returns:
- TODO
- Throws:
Exception- TODO
-
getDurableDestinations
public Set getDurableDestinations()
Get all the Destinations that are in storage- Returns:
- Set of all stored destinations
-
getInactiveDestinations
protected Set<ActiveMQDestination> getInactiveDestinations()
- Returns:
- all Destinations that don't have active consumers
-
removeConsumer
public void removeConsumer(ConnectionContext context, ConsumerInfo info) throws Exception
Description copied from interface:RegionRemoves a consumer.- Specified by:
removeConsumerin interfaceRegion- Parameters:
context- the environment the operation is being executed under.- Throws:
Exception- TODO
-
destroySubscription
protected void destroySubscription(Subscription sub)
-
removeSubscription
public void removeSubscription(ConnectionContext context, RemoveSubscriptionInfo info) throws Exception
Description copied from interface:RegionDeletes a durable subscription.- Specified by:
removeSubscriptionin interfaceRegion- Parameters:
context- the environment the operation is being executed under.info- TODO- Throws:
Exception- TODO
-
send
public void send(ProducerBrokerExchange producerExchange, Message messageSend) throws Exception
Description copied from interface:RegionSend 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.
-
acknowledge
public void acknowledge(ConsumerBrokerExchange consumerExchange, MessageAck ack) throws Exception
Description copied from interface:RegionUsed to acknowledge the receipt of a message by a client.- Specified by:
acknowledgein interfaceRegion- Parameters:
consumerExchange- the environment the operation is being executed under.- Throws:
Exception- TODO
-
messagePull
public Response messagePull(ConnectionContext context, MessagePull pull) throws Exception
Description copied from interface:RegionAllows a consumer to pull a message from a queue- Specified by:
messagePullin interfaceRegion- Throws:
Exception
-
lookup
protected Destination lookup(ConnectionContext context, ActiveMQDestination destination, boolean createTemporary) throws Exception
- Throws:
Exception
-
processDispatchNotification
public void processDispatchNotification(MessageDispatchNotification messageDispatchNotification) throws Exception
Description copied from interface:RegionProcess a notification of a dispatch - used by a Slave Broker- Specified by:
processDispatchNotificationin interfaceRegion- Throws:
Exception- TODO
-
processDispatchNotificationViaDestination
protected void processDispatchNotificationViaDestination(MessageDispatchNotification messageDispatchNotification) throws Exception
- Throws:
Exception
-
createSubscription
protected abstract Subscription createSubscription(ConnectionContext context, ConsumerInfo info) throws Exception
- Throws:
Exception
-
createDestination
protected Destination createDestination(ConnectionContext context, ActiveMQDestination destination) throws Exception
- Throws:
Exception
-
isAutoCreateDestinations
public boolean isAutoCreateDestinations()
-
setAutoCreateDestinations
public void setAutoCreateDestinations(boolean autoCreateDestinations)
-
addProducer
public void addProducer(ConnectionContext context, ProducerInfo info) throws Exception
Description copied from interface:RegionAdds a Producer.- Specified by:
addProducerin interfaceRegion- Parameters:
context- the environment the operation is being executed under.- Throws:
Exception- TODO
-
removeProducer
public void removeProducer(ConnectionContext context, ProducerInfo info) throws Exception
Removes a Producer.- Specified by:
removeProducerin interfaceRegion- Parameters:
context- the environment the operation is being executed under.- Throws:
Exception- TODO
-
dispose
protected void dispose(ConnectionContext context, Destination dest) throws Exception
- Throws:
Exception
-
processConsumerControl
public void processConsumerControl(ConsumerBrokerExchange consumerExchange, ConsumerControl control)
- Specified by:
processConsumerControlin interfaceRegion
-
reapplyInterceptor
public void reapplyInterceptor()
- Specified by:
reapplyInterceptorin interfaceRegion
-
-