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 boolean
autoCreateDestinations
protected RegionBroker
broker
protected Map<ConsumerId,Object>
consumerChangeMutexMap
protected DestinationFactory
destinationFactory
protected DestinationMap
destinationMap
protected Map<ActiveMQDestination,Destination>
destinations
protected ReentrantReadWriteLock
destinationsLock
protected DestinationStatistics
destinationStatistics
protected RegionStatistics
regionStatistics
protected boolean
started
protected Map<ConsumerId,Subscription>
subscriptions
protected TaskRunnerFactory
taskRunnerFactory
protected SystemUsage
usageManager
-
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 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 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()
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 regionSet
getDurableDestinations()
Get all the Destinations that are in storageprotected Set<ActiveMQDestination>
getInactiveDestinations()
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 queuevoid
processConsumerControl(ConsumerBrokerExchange consumerExchange, ConsumerControl control)
void
processDispatchNotification(MessageDispatchNotification messageDispatchNotification)
Process a notification of a dispatch - used by a Slave Brokerprotected void
processDispatchNotificationViaDestination(MessageDispatchNotification messageDispatchNotification)
void
reapplyInterceptor()
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()
protected void
updateRegionDestCounts(ActiveMQDestination destination, int count)
Updates the counts in RegionStatistics based on whether or not the destination is an Advisory Destination or notprotected void
validateMaxDestinations(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: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 interfaceRegion
destination
- 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: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 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:
getDestinations
in interfaceRegion
- Returns:
- a set of matching destination objects.
-
getDestinationMap
public Map<ActiveMQDestination,Destination> getDestinationMap()
Description copied from interface:Region
Returns a reference to the concurrent hash map that holds known destinations, do not modify- Specified by:
getDestinationMap
in interfaceRegion
-
addConsumer
public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception
Description copied from interface:Region
Adds a consumer.- Specified by:
addConsumer
in 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:Region
Removes a consumer.- Specified by:
removeConsumer
in 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:Region
Deletes a durable subscription.- Specified by:
removeSubscription
in 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: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.
-
acknowledge
public void acknowledge(ConsumerBrokerExchange consumerExchange, MessageAck ack) throws Exception
Description copied from interface:Region
Used to acknowledge the receipt of a message by a client.- Specified by:
acknowledge
in 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:Region
Allows a consumer to pull a message from a queue- Specified by:
messagePull
in 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:Region
Process a notification of a dispatch - used by a Slave Broker- Specified by:
processDispatchNotification
in 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:Region
Adds a Producer.- Specified by:
addProducer
in 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:
removeProducer
in 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:
processConsumerControl
in interfaceRegion
-
reapplyInterceptor
public void reapplyInterceptor()
- Specified by:
reapplyInterceptor
in interfaceRegion
-
-