public Broker installPlugin(Broker broker) throws Exception { return new ConnectionDotFileInterceptor(broker, file, redrawOnRemove); }
protected void printSubscribers(PrintWriter writer, Map<String, String> clients, Map<String, String> destinations, String type, ObjectName[] subscribers) { for (int i = 0; i < subscribers.length; i++) { ObjectName name = subscribers[i]; SubscriptionViewMBean subscriber = (SubscriptionViewMBean)getBrokerService().getManagementContext().newProxyInstance(name, SubscriptionViewMBean.class, true); String safeClientId = asID(clientId); clients.put(safeClientId, clientId); String safeDestinationId = type + asID(destination); destinations.put(safeDestinationId, destination);
@Override public void removeConsumer(ConnectionContext context, ConsumerInfo info) throws Exception { super.removeConsumer(context, info); if (redrawOnRemove) { generateFile(); } }
protected void printNodeLinks(PrintWriter writer, DestinationMapNode node, String prefix) { String path = getPath(node); Collection children = node.getChildren(); for (Iterator iter = children.iterator(); iter.hasNext();) { DestinationMapNode child = (DestinationMapNode)iter.next(); writer.print(" "); writer.print(prefix); writer.print(ID_SEPARATOR); writer.print(path); writer.print(" -> "); writer.print(prefix); writer.print(ID_SEPARATOR); writer.print(path); writer.print(ID_SEPARATOR); writer.print(getPath(child)); writer.println(";"); printNodeLinks(writer, child, prefix + ID_SEPARATOR + path); } }
@Override protected void generateFile(PrintWriter writer) throws Exception { writer.println("digraph \"ActiveMQ Connections\" {"); writer.println(); writer.println("label=\"ActiveMQ Broker: " + getBrokerView().getBrokerId() + "\"];"); writer.println(); writer.println("node [style = \"rounded,filled\", fillcolor = yellow, fontname=\"Helvetica-Oblique\"];"); writer.println(); Map<String, String> clients = new HashMap<String, String>(); Map<String, String> queues = new HashMap<String, String>(); Map<String, String> topics = new HashMap<String, String>(); printSubscribers(writer, clients, queues, "queue_", getBrokerView().getQueueSubscribers()); writer.println(); printSubscribers(writer, clients, topics, "topic_", getBrokerView().getTopicSubscribers()); writer.println(); printProducers(writer, clients, queues, topics); writer.println(); writeLabels(writer, "green", "Client: ", clients); writer.println(); writeLabels(writer, "red", "Queue: ", queues); writeLabels(writer, "blue", "Topic: ", topics); writer.println("}"); if (clearProducerCacheAfterRender) { producerDestinations.clear(); } }
protected void printNodes(PrintWriter writer, DestinationMapNode node, String prefix) { String path = getPath(node); writer.print(" "); writer.print(prefix); writer.print(ID_SEPARATOR); writer.print(path); String label = path; if (prefix.equals("topic")) { label = "Topics"; } else if (prefix.equals("queue")) { label = "Queues"; } writer.print("[ label = \""); writer.print(label); writer.println("\" ];"); Collection children = node.getChildren(); for (Iterator iter = children.iterator(); iter.hasNext();) { DestinationMapNode child = (DestinationMapNode)iter.next(); printNodes(writer, child, prefix + ID_SEPARATOR + path); } }
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; } }
protected void printProducers(PrintWriter writer, Map<String, String> clients, Map<String, String> queues, Map<String, String> topics) { synchronized (lock) { for (Iterator iter = producerDestinations.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry)iter.next(); ProducerId producerId = (ProducerId)entry.getKey(); Set destinationSet = (Set)entry.getValue(); printProducers(writer, clients, queues, topics, producerId, destinationSet); } } }
@Override protected void generateFile(PrintWriter writer) throws Exception { writer.println("digraph \"ActiveMQ Connections\" {"); writer.println(); writer.println("label=\"ActiveMQ Broker: " + getBrokerView().getBrokerId() + "\"];"); writer.println(); writer.println("node [style = \"rounded,filled\", fillcolor = yellow, fontname=\"Helvetica-Oblique\"];"); writer.println(); Map<String, String> clients = new HashMap<String, String>(); Map<String, String> queues = new HashMap<String, String>(); Map<String, String> topics = new HashMap<String, String>(); printSubscribers(writer, clients, queues, "queue_", getBrokerView().getQueueSubscribers()); writer.println(); printSubscribers(writer, clients, topics, "topic_", getBrokerView().getTopicSubscribers()); writer.println(); printProducers(writer, clients, queues, topics); writer.println(); writeLabels(writer, "green", "Client: ", clients); writer.println(); writeLabels(writer, "red", "Queue: ", queues); writeLabels(writer, "blue", "Topic: ", topics); writer.println("}"); if (clearProducerCacheAfterRender) { producerDestinations.clear(); } }
protected void printNodeLinks(PrintWriter writer, DestinationMapNode node, String prefix) { String path = getPath(node); Collection children = node.getChildren(); for (Iterator iter = children.iterator(); iter.hasNext();) { DestinationMapNode child = (DestinationMapNode)iter.next(); writer.print(" "); writer.print(prefix); writer.print(ID_SEPARATOR); writer.print(path); writer.print(" -> "); writer.print(prefix); writer.print(ID_SEPARATOR); writer.print(path); writer.print(ID_SEPARATOR); writer.print(getPath(child)); writer.println(";"); printNodeLinks(writer, child, prefix + ID_SEPARATOR + path); } }
protected void printNodes(PrintWriter writer, DestinationMapNode node, String prefix) { String path = getPath(node); writer.print(" "); writer.print(prefix); writer.print(ID_SEPARATOR); writer.print(path); String label = path; if (prefix.equals("topic")) { label = "Topics"; } else if (prefix.equals("queue")) { label = "Queues"; } writer.print("[ label = \""); writer.print(label); writer.println("\" ];"); Collection children = node.getChildren(); for (Iterator iter = children.iterator(); iter.hasNext();) { DestinationMapNode child = (DestinationMapNode)iter.next(); printNodes(writer, child, prefix + ID_SEPARATOR + path); } }
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; } }
protected void printProducers(PrintWriter writer, Map<String, String> clients, Map<String, String> queues, Map<String, String> topics) { synchronized (lock) { for (Iterator iter = producerDestinations.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry)iter.next(); ProducerId producerId = (ProducerId)entry.getKey(); Set destinationSet = (Set)entry.getValue(); printProducers(writer, clients, queues, topics, producerId, destinationSet); } } }
@Override protected void generateFile(PrintWriter writer) throws Exception { writer.println("digraph \"ActiveMQ Connections\" {"); writer.println(); writer.println("label=\"ActiveMQ Broker: " + getBrokerView().getBrokerId() + "\"];"); writer.println(); writer.println("node [style = \"rounded,filled\", fillcolor = yellow, fontname=\"Helvetica-Oblique\"];"); writer.println(); Map<String, String> clients = new HashMap<String, String>(); Map<String, String> queues = new HashMap<String, String>(); Map<String, String> topics = new HashMap<String, String>(); printSubscribers(writer, clients, queues, "queue_", getBrokerView().getQueueSubscribers()); writer.println(); printSubscribers(writer, clients, topics, "topic_", getBrokerView().getTopicSubscribers()); writer.println(); printProducers(writer, clients, queues, topics); writer.println(); writeLabels(writer, "green", "Client: ", clients); writer.println(); writeLabels(writer, "red", "Queue: ", queues); writeLabels(writer, "blue", "Topic: ", topics); writer.println("}"); if (clearProducerCacheAfterRender) { producerDestinations.clear(); } }
@Override public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception { Subscription answer = super.addConsumer(context, info); generateFile(); return answer; }
protected void printNodeLinks(PrintWriter writer, DestinationMapNode node, String prefix) { String path = getPath(node); Collection children = node.getChildren(); for (Iterator iter = children.iterator(); iter.hasNext();) { DestinationMapNode child = (DestinationMapNode)iter.next(); writer.print(" "); writer.print(prefix); writer.print(ID_SEPARATOR); writer.print(path); writer.print(" -> "); writer.print(prefix); writer.print(ID_SEPARATOR); writer.print(path); writer.print(ID_SEPARATOR); writer.print(getPath(child)); writer.println(";"); printNodeLinks(writer, child, prefix + ID_SEPARATOR + path); } }
protected void printNodes(PrintWriter writer, DestinationMapNode node, String prefix) { String path = getPath(node); writer.print(" "); writer.print(prefix); writer.print(ID_SEPARATOR); writer.print(path); String label = path; if (prefix.equals("topic")) { label = "Topics"; } else if (prefix.equals("queue")) { label = "Queues"; } writer.print("[ label = \""); writer.print(label); writer.println("\" ];"); Collection children = node.getChildren(); for (Iterator iter = children.iterator(); iter.hasNext();) { DestinationMapNode child = (DestinationMapNode)iter.next(); printNodes(writer, child, prefix + ID_SEPARATOR + path); } }
protected void printSubscribers(PrintWriter writer, Map<String, String> clients, Map<String, String> destinations, String type, ObjectName[] subscribers) { for (int i = 0; i < subscribers.length; i++) { ObjectName name = subscribers[i]; SubscriptionViewMBean subscriber = (SubscriptionViewMBean)getBrokerService().getManagementContext().newProxyInstance(name, SubscriptionViewMBean.class, true); String safeClientId = asID(clientId); clients.put(safeClientId, clientId); String safeDestinationId = type + asID(destination); destinations.put(safeDestinationId, destination);