Package org.apache.activemq.advisory
Class AdvisoryBroker
- java.lang.Object
-
- org.apache.activemq.broker.BrokerFilter
-
- org.apache.activemq.advisory.AdvisoryBroker
-
public class AdvisoryBroker extends BrokerFilter
This broker filter handles tracking the state of the broker for purposes of publishing advisory messages to advisory consumers.
-
-
Field Summary
Fields Modifier and Type Field Description protected ProducerIdadvisoryProducerIdprotected ConcurrentMap<org.apache.activemq.advisory.AdvisoryBroker.VirtualConsumerPair,ConsumerInfo>brokerConsumerDestsThis is a map to track unique demand for the existence of a virtual destination so we make sure we don't send duplicate advisories.protected ConcurrentMap<ConnectionId,ConnectionInfo>connectionsprotected Map<ConsumerId,ConsumerInfo>consumersprotected ConcurrentMap<ActiveMQDestination,DestinationInfo>destinationsprotected ConcurrentMap<BrokerInfo,ActiveMQMessage>networkBridgesprotected ConcurrentMap<ProducerId,ProducerInfo>producersprotected ConcurrentMap<ConsumerInfo,VirtualDestination>virtualDestinationConsumersThis is a map to track all consumers that exist on the virtual destination so that we can fire an advisory later when they go away to remove the demand.protected Set<VirtualDestination>virtualDestinationsThis is a set to track all of the virtual destinations that have been added to the broker so they can be easily referenced later.-
Fields inherited from class org.apache.activemq.broker.BrokerFilter
next
-
-
Constructor Summary
Constructors Constructor Description AdvisoryBroker(Broker next)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConnection(ConnectionContext context, ConnectionInfo info)A client is establishing a connection with the broker.SubscriptionaddConsumer(ConnectionContext context, ConsumerInfo info)Adds a consumer.DestinationaddDestination(ConnectionContext context, ActiveMQDestination destination, boolean create)Used to create a destination.voidaddDestinationInfo(ConnectionContext context, DestinationInfo info)Add and process a DestinationInfo objectvoidaddProducer(ConnectionContext context, ProducerInfo info)Adds a producer.voidfastProducer(ConnectionContext context, ProducerInfo producerInfo, ActiveMQDestination destination)Called to notify a producer is too fastprotected voidfireAdvisory(ConnectionContext context, ActiveMQTopic topic, Command command)protected voidfireAdvisory(ConnectionContext context, ActiveMQTopic topic, Command command, ConsumerId targetConsumerId)voidfireAdvisory(ConnectionContext context, ActiveMQTopic topic, Command command, ConsumerId targetConsumerId, ActiveMQMessage advisoryMessage)protected voidfireConsumerAdvisory(ConnectionContext context, ActiveMQDestination consumerDestination, ActiveMQTopic topic, Command command)protected voidfireConsumerAdvisory(ConnectionContext context, ActiveMQDestination consumerDestination, ActiveMQTopic topic, Command command, ConsumerId targetConsumerId)protected voidfireProducerAdvisory(ConnectionContext context, ActiveMQDestination producerDestination, ActiveMQTopic topic, Command command)protected voidfireProducerAdvisory(ConnectionContext context, ActiveMQDestination producerDestination, ActiveMQTopic topic, Command command, ConsumerId targetConsumerId)Map<ConnectionId,ConnectionInfo>getAdvisoryConnections()Collection<ConsumerInfo>getAdvisoryConsumers()Map<ActiveMQDestination,DestinationInfo>getAdvisoryDestinations()Map<ProducerId,ProducerInfo>getAdvisoryProducers()ConcurrentMap<ConsumerInfo,VirtualDestination>getVirtualDestinationConsumers()voidisFull(ConnectionContext context, Destination destination, Usage<?> usage)Called when a Usage reaches a limitvoidmessageConsumed(ConnectionContext context, MessageReference messageReference)called when message is consumedvoidmessageDelivered(ConnectionContext context, MessageReference messageReference)Called when message is delivered to the brokervoidmessageDiscarded(ConnectionContext context, Subscription sub, MessageReference messageReference)Called when a message is discarded - e.g.voidmessageExpired(ConnectionContext context, MessageReference messageReference, Subscription subscription)A Message has ExpiredvoidnetworkBridgeStarted(BrokerInfo brokerInfo, boolean createdByDuplex, String remoteIp)voidnetworkBridgeStopped(BrokerInfo brokerInfo)voidnowMasterBroker()called when the broker becomes the master in a master/slave configurationvoidremoveConnection(ConnectionContext context, ConnectionInfo info, Throwable error)A client is disconnecting from the broker.voidremoveConsumer(ConnectionContext context, ConsumerInfo info)Removes a consumer.voidremoveDestination(ConnectionContext context, ActiveMQDestination destination, long timeout)Used to destroy a destination.voidremoveDestinationInfo(ConnectionContext context, DestinationInfo destInfo)Remove and process a DestinationInfo objectvoidremoveProducer(ConnectionContext context, ProducerInfo info)Removes a producer.voidremoveSubscription(ConnectionContext context, RemoveSubscriptionInfo info)Deletes a durable subscription.booleansendToDeadLetterQueue(ConnectionContext context, MessageReference messageReference, Subscription subscription, Throwable poisonCause)A message needs to go the a DLQvoidslowConsumer(ConnectionContext context, Destination destination, Subscription subs)Called when there is a slow consumervoidvirtualDestinationAdded(ConnectionContext context, VirtualDestination virtualDestination)voidvirtualDestinationRemoved(ConnectionContext context, VirtualDestination virtualDestination)-
Methods inherited from class org.apache.activemq.broker.BrokerFilter
acknowledge, addBroker, addSession, beginTransaction, brokerServiceStarted, commitTransaction, forgetTransaction, gc, getAdaptor, getAdminConnectionContext, getBrokerId, getBrokerName, getBrokerSequenceId, getBrokerService, getClients, getDestinationMap, getDestinationMap, getDestinations, getDestinations, getDurableDestinations, getExecutor, getNext, getPeerBrokerInfos, getPreparedTransactions, getRoot, getScheduler, getTempDataStore, getVmConnectorURI, isExpired, isFaultTolerantConfiguration, isStopped, messagePull, postProcessDispatch, prepareTransaction, preProcessDispatch, processConsumerControl, processDispatchNotification, reapplyInterceptor, removeBroker, removeSession, rollbackTransaction, send, setAdminConnectionContext, start, stop
-
-
-
-
Field Detail
-
connections
protected final ConcurrentMap<ConnectionId,ConnectionInfo> connections
-
consumers
protected final Map<ConsumerId,ConsumerInfo> consumers
-
virtualDestinations
protected final Set<VirtualDestination> virtualDestinations
This is a set to track all of the virtual destinations that have been added to the broker so they can be easily referenced later.
-
virtualDestinationConsumers
protected final ConcurrentMap<ConsumerInfo,VirtualDestination> virtualDestinationConsumers
This is a map to track all consumers that exist on the virtual destination so that we can fire an advisory later when they go away to remove the demand.
-
brokerConsumerDests
protected final ConcurrentMap<org.apache.activemq.advisory.AdvisoryBroker.VirtualConsumerPair,ConsumerInfo> brokerConsumerDests
This is a map to track unique demand for the existence of a virtual destination so we make sure we don't send duplicate advisories.
-
producers
protected final ConcurrentMap<ProducerId,ProducerInfo> producers
-
destinations
protected final ConcurrentMap<ActiveMQDestination,DestinationInfo> destinations
-
networkBridges
protected final ConcurrentMap<BrokerInfo,ActiveMQMessage> networkBridges
-
advisoryProducerId
protected final ProducerId advisoryProducerId
-
-
Constructor Detail
-
AdvisoryBroker
public AdvisoryBroker(Broker next)
-
-
Method Detail
-
addConnection
public void addConnection(ConnectionContext context, ConnectionInfo info) throws Exception
Description copied from interface:BrokerA client is establishing a connection with the broker.- Specified by:
addConnectionin interfaceBroker- Overrides:
addConnectionin classBrokerFilter- Throws:
Exception- TODO
-
addConsumer
public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception
Description copied from interface:RegionAdds a consumer.- Specified by:
addConsumerin interfaceRegion- Overrides:
addConsumerin classBrokerFilter- Parameters:
context- the environment the operation is being executed under.- Returns:
- TODO
- Throws:
Exception- TODO
-
addProducer
public void addProducer(ConnectionContext context, ProducerInfo info) throws Exception
Description copied from interface:BrokerAdds a producer.- Specified by:
addProducerin interfaceBroker- Specified by:
addProducerin interfaceRegion- Overrides:
addProducerin classBrokerFilter- Parameters:
context- the environment the operation is being executed under.- Throws:
Exception- TODO
-
addDestination
public Destination addDestination(ConnectionContext context, ActiveMQDestination destination, boolean create) 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 interfaceRegion- Overrides:
addDestinationin classBrokerFilterdestination- the destination to create.- Returns:
- TODO
- Throws:
Exception- TODO
-
addDestinationInfo
public void addDestinationInfo(ConnectionContext context, DestinationInfo info) throws Exception
Description copied from interface:BrokerAdd and process a DestinationInfo object- Specified by:
addDestinationInfoin interfaceBroker- Overrides:
addDestinationInfoin classBrokerFilter- 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- Overrides:
removeDestinationin classBrokerFilter- 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
-
removeDestinationInfo
public void removeDestinationInfo(ConnectionContext context, DestinationInfo destInfo) throws Exception
Description copied from interface:BrokerRemove and process a DestinationInfo object- Specified by:
removeDestinationInfoin interfaceBroker- Overrides:
removeDestinationInfoin classBrokerFilter- Throws:
Exception
-
removeConnection
public void removeConnection(ConnectionContext context, ConnectionInfo info, Throwable error) throws Exception
Description copied from interface:BrokerA client is disconnecting from the broker.- Specified by:
removeConnectionin interfaceBroker- Overrides:
removeConnectionin classBrokerFilter- Parameters:
context- the environment the operation is being executed under.error- null if the client requested the disconnect or the error that caused the client to disconnect.- Throws:
Exception- TODO
-
removeConsumer
public void removeConsumer(ConnectionContext context, ConsumerInfo info) throws Exception
Description copied from interface:RegionRemoves a consumer.- Specified by:
removeConsumerin interfaceRegion- Overrides:
removeConsumerin classBrokerFilter- Parameters:
context- the environment the operation is being executed under.- Throws:
Exception- TODO
-
removeSubscription
public void removeSubscription(ConnectionContext context, RemoveSubscriptionInfo info) throws Exception
Description copied from interface:RegionDeletes a durable subscription.- Specified by:
removeSubscriptionin interfaceRegion- Overrides:
removeSubscriptionin classBrokerFilter- Parameters:
context- the environment the operation is being executed under.info- TODO- Throws:
Exception- TODO
-
removeProducer
public void removeProducer(ConnectionContext context, ProducerInfo info) throws Exception
Description copied from interface:BrokerRemoves a producer.- Specified by:
removeProducerin interfaceBroker- Specified by:
removeProducerin interfaceRegion- Overrides:
removeProducerin classBrokerFilter- Parameters:
context- the environment the operation is being executed under.- Throws:
Exception- TODO
-
messageExpired
public void messageExpired(ConnectionContext context, MessageReference messageReference, Subscription subscription)
Description copied from interface:BrokerA Message has Expired- Specified by:
messageExpiredin interfaceBroker- Overrides:
messageExpiredin classBrokerFiltersubscription- (may be null)
-
messageConsumed
public void messageConsumed(ConnectionContext context, MessageReference messageReference)
Description copied from interface:Brokercalled when message is consumed- Specified by:
messageConsumedin interfaceBroker- Overrides:
messageConsumedin classBrokerFilter
-
messageDelivered
public void messageDelivered(ConnectionContext context, MessageReference messageReference)
Description copied from interface:BrokerCalled when message is delivered to the broker- Specified by:
messageDeliveredin interfaceBroker- Overrides:
messageDeliveredin classBrokerFilter
-
messageDiscarded
public void messageDiscarded(ConnectionContext context, Subscription sub, MessageReference messageReference)
Description copied from interface:BrokerCalled when a message is discarded - e.g. running low on memory This will happen only if the policy is enabled - e.g. non durable topics- Specified by:
messageDiscardedin interfaceBroker- Overrides:
messageDiscardedin classBrokerFilter
-
slowConsumer
public void slowConsumer(ConnectionContext context, Destination destination, Subscription subs)
Description copied from interface:BrokerCalled when there is a slow consumer- Specified by:
slowConsumerin interfaceBroker- Overrides:
slowConsumerin classBrokerFilter
-
fastProducer
public void fastProducer(ConnectionContext context, ProducerInfo producerInfo, ActiveMQDestination destination)
Description copied from interface:BrokerCalled to notify a producer is too fast- Specified by:
fastProducerin interfaceBroker- Overrides:
fastProducerin classBrokerFilter
-
virtualDestinationAdded
public void virtualDestinationAdded(ConnectionContext context, VirtualDestination virtualDestination)
- Specified by:
virtualDestinationAddedin interfaceBroker- Overrides:
virtualDestinationAddedin classBrokerFilter
-
virtualDestinationRemoved
public void virtualDestinationRemoved(ConnectionContext context, VirtualDestination virtualDestination)
- Specified by:
virtualDestinationRemovedin interfaceBroker- Overrides:
virtualDestinationRemovedin classBrokerFilter
-
isFull
public void isFull(ConnectionContext context, Destination destination, Usage<?> usage)
Description copied from interface:BrokerCalled when a Usage reaches a limit- Specified by:
isFullin interfaceBroker- Overrides:
isFullin classBrokerFilter
-
nowMasterBroker
public void nowMasterBroker()
Description copied from interface:Brokercalled when the broker becomes the master in a master/slave configuration- Specified by:
nowMasterBrokerin interfaceBroker- Overrides:
nowMasterBrokerin classBrokerFilter
-
sendToDeadLetterQueue
public boolean sendToDeadLetterQueue(ConnectionContext context, MessageReference messageReference, Subscription subscription, Throwable poisonCause)
Description copied from interface:BrokerA message needs to go the a DLQ- Specified by:
sendToDeadLetterQueuein interfaceBroker- Overrides:
sendToDeadLetterQueuein classBrokerFilterpoisonCause- reason for dlq submission, may be null- Returns:
- true if Message was placed in a DLQ false if discarded.
-
networkBridgeStarted
public void networkBridgeStarted(BrokerInfo brokerInfo, boolean createdByDuplex, String remoteIp)
- Specified by:
networkBridgeStartedin interfaceBroker- Overrides:
networkBridgeStartedin classBrokerFilter
-
networkBridgeStopped
public void networkBridgeStopped(BrokerInfo brokerInfo)
- Specified by:
networkBridgeStoppedin interfaceBroker- Overrides:
networkBridgeStoppedin classBrokerFilter
-
fireAdvisory
protected void fireAdvisory(ConnectionContext context, ActiveMQTopic topic, Command command) throws Exception
- Throws:
Exception
-
fireAdvisory
protected void fireAdvisory(ConnectionContext context, ActiveMQTopic topic, Command command, ConsumerId targetConsumerId) throws Exception
- Throws:
Exception
-
fireConsumerAdvisory
protected void fireConsumerAdvisory(ConnectionContext context, ActiveMQDestination consumerDestination, ActiveMQTopic topic, Command command) throws Exception
- Throws:
Exception
-
fireConsumerAdvisory
protected void fireConsumerAdvisory(ConnectionContext context, ActiveMQDestination consumerDestination, ActiveMQTopic topic, Command command, ConsumerId targetConsumerId) throws Exception
- Throws:
Exception
-
fireProducerAdvisory
protected void fireProducerAdvisory(ConnectionContext context, ActiveMQDestination producerDestination, ActiveMQTopic topic, Command command) throws Exception
- Throws:
Exception
-
fireProducerAdvisory
protected void fireProducerAdvisory(ConnectionContext context, ActiveMQDestination producerDestination, ActiveMQTopic topic, Command command, ConsumerId targetConsumerId) throws Exception
- Throws:
Exception
-
fireAdvisory
public void fireAdvisory(ConnectionContext context, ActiveMQTopic topic, Command command, ConsumerId targetConsumerId, ActiveMQMessage advisoryMessage) throws Exception
- Throws:
Exception
-
getAdvisoryConnections
public Map<ConnectionId,ConnectionInfo> getAdvisoryConnections()
-
getAdvisoryConsumers
public Collection<ConsumerInfo> getAdvisoryConsumers()
-
getAdvisoryProducers
public Map<ProducerId,ProducerInfo> getAdvisoryProducers()
-
getAdvisoryDestinations
public Map<ActiveMQDestination,DestinationInfo> getAdvisoryDestinations()
-
getVirtualDestinationConsumers
public ConcurrentMap<ConsumerInfo,VirtualDestination> getVirtualDestinationConsumers()
-
-