In the case of built-in ActiveMQ, you can use BrokerService so that consumers count on the topic. The code is written in Scala, but in Java there shouldn't be much difference.
import org.apache.activemq.broker.{Broker, BrokerService, TransportConnector} val brokerService = new BrokerService() brokerService.setBrokerName("localhost") brokerService.setUseJmx(false) val transportConnector: TransportConnector = brokerServiceSetup.addConnector(s"tcp://localhost:61616") brokerService.start() brokerService.getDestination(new ActiveMQTopic(topicName)) topic.getConsumers
Łukasz Gawron
source share