Class AdvisoryBroker

java.lang.Object
org.apache.activemq.broker.BrokerFilter
org.apache.activemq.advisory.AdvisoryBroker
All Implemented Interfaces:
Broker, Region, org.apache.activemq.Service

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 Details

    • connections

      protected final ConcurrentMap<org.apache.activemq.command.ConnectionId,org.apache.activemq.command.ConnectionInfo> connections
    • consumers

      protected final Map<org.apache.activemq.command.ConsumerId,org.apache.activemq.command.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<org.apache.activemq.command.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,org.apache.activemq.command.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<org.apache.activemq.command.ProducerId,org.apache.activemq.command.ProducerInfo> producers
    • destinations

      protected final ConcurrentMap<org.apache.activemq.command.ActiveMQDestination,org.apache.activemq.command.DestinationInfo> destinations
    • networkBridges

      protected final ConcurrentMap<org.apache.activemq.command.BrokerInfo,org.apache.activemq.command.ActiveMQMessage> networkBridges
    • advisoryProducerId

      protected final org.apache.activemq.command.ProducerId advisoryProducerId
  • Constructor Details

    • AdvisoryBroker

      public AdvisoryBroker(Broker next)
  • Method Details

    • addConnection

      public void addConnection(ConnectionContext context, org.apache.activemq.command.ConnectionInfo info) throws Exception
      Description copied from interface: Broker
      A client is establishing a connection with the broker.
      Specified by:
      addConnection in interface Broker
      Overrides:
      addConnection in class BrokerFilter
      Throws:
      Exception - TODO
    • addConsumer

      public Subscription addConsumer(ConnectionContext context, org.apache.activemq.command.ConsumerInfo info) throws Exception
      Description copied from interface: Region
      Adds a consumer.
      Specified by:
      addConsumer in interface Region
      Overrides:
      addConsumer in class BrokerFilter
      Parameters:
      context - the environment the operation is being executed under.
      Returns:
      TODO
      Throws:
      Exception - TODO
    • addProducer

      public void addProducer(ConnectionContext context, org.apache.activemq.command.ProducerInfo info) throws Exception
      Description copied from interface: Broker
      Adds a producer.
      Specified by:
      addProducer in interface Broker
      Specified by:
      addProducer in interface Region
      Overrides:
      addProducer in class BrokerFilter
      Parameters:
      context - the environment the operation is being executed under.
      Throws:
      Exception - TODO
    • addDestination

      public Destination addDestination(ConnectionContext context, org.apache.activemq.command.ActiveMQDestination destination, boolean create) 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 interface Region
      Overrides:
      addDestination in class BrokerFilter
      destination - the destination to create.
      Returns:
      TODO
      Throws:
      Exception - TODO
    • addDestinationInfo

      public void addDestinationInfo(ConnectionContext context, org.apache.activemq.command.DestinationInfo info) throws Exception
      Description copied from interface: Broker
      Add and process a DestinationInfo object
      Specified by:
      addDestinationInfo in interface Broker
      Overrides:
      addDestinationInfo in class BrokerFilter
      Parameters:
      context - connection context
      info - destination info
      Throws:
      Exception - TODO
    • removeDestination

      public void removeDestination(ConnectionContext context, org.apache.activemq.command.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 interface Region
      Overrides:
      removeDestination in class BrokerFilter
      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, org.apache.activemq.command.DestinationInfo destInfo) throws Exception
      Description copied from interface: Broker
      Remove and process a DestinationInfo object
      Specified by:
      removeDestinationInfo in interface Broker
      Overrides:
      removeDestinationInfo in class BrokerFilter
      Parameters:
      context - connection context
      destInfo - destination info
      Throws:
      Exception - TODO
    • removeConnection

      public void removeConnection(ConnectionContext context, org.apache.activemq.command.ConnectionInfo info, Throwable error) throws Exception
      Description copied from interface: Broker
      A client is disconnecting from the broker.
      Specified by:
      removeConnection in interface Broker
      Overrides:
      removeConnection in class BrokerFilter
      Parameters:
      context - the environment the operation is being executed under.
      info - metadata about the Broker
      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, org.apache.activemq.command.ConsumerInfo info) throws Exception
      Description copied from interface: Region
      Removes a consumer.
      Specified by:
      removeConsumer in interface Region
      Overrides:
      removeConsumer in class BrokerFilter
      Parameters:
      context - the environment the operation is being executed under.
      Throws:
      Exception - TODO
    • removeSubscription

      public void removeSubscription(ConnectionContext context, org.apache.activemq.command.RemoveSubscriptionInfo info) throws Exception
      Description copied from interface: Region
      Deletes a durable subscription.
      Specified by:
      removeSubscription in interface Region
      Overrides:
      removeSubscription in class BrokerFilter
      Parameters:
      context - the environment the operation is being executed under.
      info - TODO
      Throws:
      Exception - TODO
    • removeProducer

      public void removeProducer(ConnectionContext context, org.apache.activemq.command.ProducerInfo info) throws Exception
      Description copied from interface: Broker
      Removes a producer.
      Specified by:
      removeProducer in interface Broker
      Specified by:
      removeProducer in interface Region
      Overrides:
      removeProducer in class BrokerFilter
      Parameters:
      context - the environment the operation is being executed under.
      Throws:
      Exception - TODO
    • messageExpired

      public void messageExpired(ConnectionContext context, org.apache.activemq.broker.region.MessageReference messageReference, Subscription subscription)
      Description copied from interface: Broker
      A Message has Expired
      Specified by:
      messageExpired in interface Broker
      Overrides:
      messageExpired in class BrokerFilter
      Parameters:
      context - connection context
      messageReference - message reference
      subscription - (maybe null)
    • messageConsumed

      public void messageConsumed(ConnectionContext context, org.apache.activemq.broker.region.MessageReference messageReference)
      Description copied from interface: Broker
      called when message is consumed
      Specified by:
      messageConsumed in interface Broker
      Overrides:
      messageConsumed in class BrokerFilter
      Parameters:
      context - connection context
      messageReference - message reference
    • messageDelivered

      public void messageDelivered(ConnectionContext context, org.apache.activemq.broker.region.MessageReference messageReference)
      Description copied from interface: Broker
      Called when message is delivered to the broker
      Specified by:
      messageDelivered in interface Broker
      Overrides:
      messageDelivered in class BrokerFilter
      Parameters:
      context - connection context
      messageReference - message reference
    • messageDispatched

      public void messageDispatched(ConnectionContext context, Subscription sub, org.apache.activemq.broker.region.MessageReference messageReference)
      Description copied from interface: Broker
      Called when message is dispatched to a consumer
      Specified by:
      messageDispatched in interface Broker
      Overrides:
      messageDispatched in class BrokerFilter
      Parameters:
      context - connection context
      sub - subscription
      messageReference - message reference
    • messageDiscarded

      public void messageDiscarded(ConnectionContext context, Subscription sub, org.apache.activemq.broker.region.MessageReference messageReference)
      Description copied from interface: Broker
      Called 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:
      messageDiscarded in interface Broker
      Overrides:
      messageDiscarded in class BrokerFilter
      Parameters:
      context - connection context
      sub - subscription
      messageReference - message reference
    • slowConsumer

      public void slowConsumer(ConnectionContext context, Destination destination, Subscription subs)
      Description copied from interface: Broker
      Called when there is a slow consumer
      Specified by:
      slowConsumer in interface Broker
      Overrides:
      slowConsumer in class BrokerFilter
      Parameters:
      context - connection context
      destination - destination
      subs - subscription
    • fastProducer

      public void fastProducer(ConnectionContext context, org.apache.activemq.command.ProducerInfo producerInfo, org.apache.activemq.command.ActiveMQDestination destination)
      Description copied from interface: Broker
      Called to notify a producer is too fast
      Specified by:
      fastProducer in interface Broker
      Overrides:
      fastProducer in class BrokerFilter
      Parameters:
      context - connection context
      producerInfo - producer info
      destination - destination
    • virtualDestinationAdded

      public void virtualDestinationAdded(ConnectionContext context, VirtualDestination virtualDestination)
      Specified by:
      virtualDestinationAdded in interface Broker
      Overrides:
      virtualDestinationAdded in class BrokerFilter
    • virtualDestinationRemoved

      public void virtualDestinationRemoved(ConnectionContext context, VirtualDestination virtualDestination)
      Specified by:
      virtualDestinationRemoved in interface Broker
      Overrides:
      virtualDestinationRemoved in class BrokerFilter
    • isFull

      public void isFull(ConnectionContext context, Destination destination, org.apache.activemq.usage.Usage<?> usage)
      Description copied from interface: Broker
      Called when a Usage reaches a limit
      Specified by:
      isFull in interface Broker
      Overrides:
      isFull in class BrokerFilter
      Parameters:
      context - create new scratch file from selection
      destination - destination
      usage - usage
    • nowMasterBroker

      public void nowMasterBroker()
      Description copied from interface: Broker
      called when the broker becomes the master in a master/slave configuration
      Specified by:
      nowMasterBroker in interface Broker
      Overrides:
      nowMasterBroker in class BrokerFilter
    • sendToDeadLetterQueue

      public boolean sendToDeadLetterQueue(ConnectionContext context, org.apache.activemq.broker.region.MessageReference messageReference, Subscription subscription, Throwable poisonCause)
      Description copied from interface: Broker
      A message needs to go to the DLQ
      Specified by:
      sendToDeadLetterQueue in interface Broker
      Overrides:
      sendToDeadLetterQueue in class BrokerFilter
      Parameters:
      context - connection context
      messageReference - message reference
      poisonCause - reason for dlq submission, may be null
      Returns:
      true if Message was placed in a DLQ false if discarded.
    • networkBridgeStarted

      public void networkBridgeStarted(org.apache.activemq.command.BrokerInfo brokerInfo, boolean createdByDuplex, String remoteIp)
      Description copied from interface: Broker
      called to when a network bridge is started
      Specified by:
      networkBridgeStarted in interface Broker
      Overrides:
      networkBridgeStarted in class BrokerFilter
      Parameters:
      brokerInfo - metadata about the broker
      createdByDuplex - is created by duplex
      remoteIp - ip address of the broker
    • networkBridgeStopped

      public void networkBridgeStopped(org.apache.activemq.command.BrokerInfo brokerInfo)
      Description copied from interface: Broker
      called to when a network bridge is stopped
      Specified by:
      networkBridgeStopped in interface Broker
      Overrides:
      networkBridgeStopped in class BrokerFilter
      Parameters:
      brokerInfo - metadata about the broker
    • fireAdvisory

      protected void fireAdvisory(ConnectionContext context, org.apache.activemq.command.ActiveMQTopic topic, org.apache.activemq.command.Command command) throws Exception
      Throws:
      Exception
    • fireAdvisory

      protected void fireAdvisory(ConnectionContext context, org.apache.activemq.command.ActiveMQTopic topic, org.apache.activemq.command.Command command, org.apache.activemq.command.ConsumerId targetConsumerId) throws Exception
      Throws:
      Exception
    • fireConsumerAdvisory

      protected void fireConsumerAdvisory(ConnectionContext context, org.apache.activemq.command.ActiveMQDestination consumerDestination, org.apache.activemq.command.ActiveMQTopic topic, org.apache.activemq.command.Command command) throws Exception
      Throws:
      Exception
    • fireConsumerAdvisory

      protected void fireConsumerAdvisory(ConnectionContext context, org.apache.activemq.command.ActiveMQDestination consumerDestination, org.apache.activemq.command.ActiveMQTopic topic, org.apache.activemq.command.Command command, org.apache.activemq.command.ConsumerId targetConsumerId) throws Exception
      Throws:
      Exception
    • fireProducerAdvisory

      protected void fireProducerAdvisory(ConnectionContext context, org.apache.activemq.command.ActiveMQDestination producerDestination, org.apache.activemq.command.ActiveMQTopic topic, org.apache.activemq.command.Command command) throws Exception
      Throws:
      Exception
    • fireProducerAdvisory

      protected void fireProducerAdvisory(ConnectionContext context, org.apache.activemq.command.ActiveMQDestination producerDestination, org.apache.activemq.command.ActiveMQTopic topic, org.apache.activemq.command.Command command, org.apache.activemq.command.ConsumerId targetConsumerId) throws Exception
      Throws:
      Exception
    • fireAdvisory

      public void fireAdvisory(ConnectionContext context, org.apache.activemq.command.ActiveMQTopic topic, org.apache.activemq.command.Command command, org.apache.activemq.command.ConsumerId targetConsumerId, org.apache.activemq.command.ActiveMQMessage advisoryMessage) throws Exception
      Throws:
      Exception
    • getAdvisoryConnections

      public Map<org.apache.activemq.command.ConnectionId,org.apache.activemq.command.ConnectionInfo> getAdvisoryConnections()
    • getAdvisoryConsumers

      public Collection<org.apache.activemq.command.ConsumerInfo> getAdvisoryConsumers()
    • getAdvisoryProducers

      public Map<org.apache.activemq.command.ProducerId,org.apache.activemq.command.ProducerInfo> getAdvisoryProducers()
    • getAdvisoryDestinations

      public Map<org.apache.activemq.command.ActiveMQDestination,org.apache.activemq.command.DestinationInfo> getAdvisoryDestinations()
    • getVirtualDestinationConsumers

      public ConcurrentMap<org.apache.activemq.command.ConsumerInfo,VirtualDestination> getVirtualDestinationConsumers()