@Override public void removeConsumer(ConnectionContext context, ConsumerInfo info) throws Exception { super.removeConsumer(context, info); if (redrawOnRemove) { generateFile(); } }
@Override public void removeDestination(ConnectionContext context, ActiveMQDestination destination, long timeout) throws Exception { super.removeDestination(context, destination, timeout); generateFile(); }
@Override public Destination addDestination(ConnectionContext context, ActiveMQDestination destination,boolean create) throws Exception { Destination answer = super.addDestination(context, destination,create); generateFile(); return answer; }
@Override public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception { Subscription answer = super.addConsumer(context, info); generateFile(); return answer; }
@Override public void addProducer(ConnectionContext context, ProducerInfo info) throws Exception { super.addProducer(context, info); ProducerId producerId = info.getProducerId(); synchronized (lock) { producers.put(producerId, info); } generateFile(); }
@Override public void removeProducer(ConnectionContext context, ProducerInfo info) throws Exception { super.removeProducer(context, info); ProducerId producerId = info.getProducerId(); if (redrawOnRemove) { synchronized (lock) { producerDestinations.remove(producerId); producers.remove(producerId); } generateFile(); } }
@Test public void testBrokerDestinationView() throws Exception { for (int i = 0; i < messageCount; i++){ Message message = producerSession.createTextMessage("test " + i); producer.send(message); } MessageBrokerView messageBrokerView = MessageBrokerViewRegistry.getInstance().lookup(""); BrokerDestinationView destinationView = messageBrokerView.getQueueDestinationView(getClass().getName()); assertEquals(destinationView.getQueueSize(),messageCount); } }
/** * It will be assumed the destinationName is prepended with topic:// or queue:// - but * will default to a Queue * @param destinationName * @return the BrokerDestinationView associated with the destinationName * @throws Exception */ public BrokerDestinationView getDestinationView(String destinationName) throws Exception{ return getDestinationView(destinationName,ActiveMQDestination.QUEUE_TYPE); }
/** * Retrieve a set of all Queues be used by the Broker * @return all Queues */ public Set<ActiveMQQueue> getQueues(){ Set<ActiveMQQueue> result = new HashSet<ActiveMQQueue>(); for (ActiveMQDestination destination:getDestinations()){ if (destination.isQueue() && !destination.isTemporary()){ result.add((ActiveMQQueue) destination); } } return result; }
public Broker installPlugin(Broker broker) { return new DestinationDotFileInterceptor(broker, file); }
public Broker installPlugin(Broker broker) throws Exception { return new ConnectionDotFileInterceptor(broker, file, redrawOnRemove); }
protected void generateFile() throws Exception { log.debug("Creating DOT file at: {}", file); PrintWriter writer = new PrintWriter(new FileWriter(file)); try { generateFile(writer); } finally { writer.close(); } }
BrokerViewMBean getBrokerView() throws Exception { if (this.brokerView == null) { ObjectName brokerName = getBrokerService().getBrokerObjectName(); this.brokerView = (BrokerViewMBean) getBrokerService().getManagementContext().newProxyInstance(brokerName, BrokerViewMBean.class, true); } return this.brokerView; } }
/** * @param brokerName * @return the BrokerService */ public MessageBrokerView lookup(String brokerName) { MessageBrokerView result = null; synchronized (mutex) { result = brokerViews.get(brokerName); if (result==null){ BrokerService brokerService = BrokerRegistry.getInstance().lookup(brokerName); if (brokerService != null){ result = new MessageBrokerView(brokerService); brokerViews.put(brokerName,result); } } } return result; } }
/** * Get the BrokerDestinationView associated with the topic * @param destinationName * @return BrokerDestinationView * @throws Exception */ public BrokerDestinationView getTopicDestinationView(String destinationName) throws Exception{ return getDestinationView(destinationName,ActiveMQDestination.TOPIC_TYPE); }
/** * Retrieve a set of all Topics be used by the Broker * @return all Topics */ public Set<ActiveMQTopic> getTopics(){ Set<ActiveMQTopic> result = new HashSet<ActiveMQTopic>(); for (ActiveMQDestination destination:getDestinations()){ if (destination.isTopic() && !destination.isTemporary()){ result.add((ActiveMQTopic) destination); } } return result; }
/** * Get the BrokerDestinationView associated with the queue * @param destinationName * @return BrokerDestinationView * @throws Exception */ public BrokerDestinationView getQueueDestinationView(String destinationName) throws Exception{ return getDestinationView(destinationName,ActiveMQDestination.QUEUE_TYPE); }
/** * Retrieve a set of all TemporaryTopics be used by the Broker * @return all TemporaryTopics */ public Set<ActiveMQTempTopic> getTempTopics(){ Set<ActiveMQTempTopic> result = new HashSet<ActiveMQTempTopic>(); for (ActiveMQDestination destination:getDestinations()){ if (destination.isTopic() && destination.isTemporary()){ result.add((ActiveMQTempTopic) destination); } } return result; }
/** * Get the BrokerDestinationView associated with destination * @param destinationName * @param type expects either ActiveMQDestination.QUEUE_TYPE, ActiveMQDestination.TOPIC_TYPE etc * @return BrokerDestinationView * @throws Exception */ public BrokerDestinationView getDestinationView (String destinationName, byte type) throws Exception { ActiveMQDestination activeMQDestination = ActiveMQDestination.createDestination(destinationName,type); return getDestinationView(activeMQDestination); }
/** * Retrieve a set of all TemporaryQueues be used by the Broker * @return all TemporaryQueues */ public Set<ActiveMQTempQueue> getTempQueues(){ Set<ActiveMQTempQueue> result = new HashSet<ActiveMQTempQueue>(); for (ActiveMQDestination destination:getDestinations()){ if (destination.isQueue() && destination.isTemporary()){ result.add((ActiveMQTempQueue) destination); } } return result; }