Class ConsumerEventSource

java.lang.Object
org.apache.activemq.advisory.ConsumerEventSource
All Implemented Interfaces:
jakarta.jms.MessageListener, Service

public class ConsumerEventSource extends Object implements Service, jakarta.jms.MessageListener
An object which can be used to listen to the number of active consumers available on a given destination.
  • Constructor Details

    • ConsumerEventSource

      public ConsumerEventSource(jakarta.jms.Connection connection, jakarta.jms.Destination destination) throws jakarta.jms.JMSException
      Throws:
      jakarta.jms.JMSException
  • Method Details

    • setConsumerListener

      public void setConsumerListener(ConsumerListener listener)
    • getConsumerId

      public String getConsumerId()
    • start

      public void start() throws Exception
      Specified by:
      start in interface Service
      Throws:
      Exception
    • stop

      public void stop() throws Exception
      Specified by:
      stop in interface Service
      Throws:
      Exception
    • onMessage

      public void onMessage(jakarta.jms.Message message)
      Specified by:
      onMessage in interface jakarta.jms.MessageListener
    • extractConsumerCountFromMessage

      protected int extractConsumerCountFromMessage(jakarta.jms.Message message, int count)
      Lets rely by default on the broker telling us what the consumer count is as it can ensure that we are up to date at all times and have not received messages out of order etc.
    • fireConsumerEvent

      protected void fireConsumerEvent(ConsumerEvent event)