/** * @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; } }
/** * 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; }
@Override public List<String> completeEndpointPath(ComponentConfiguration componentConfiguration, String completionText) { String brokerName = String.valueOf(componentConfiguration.getParameter("brokerName")); MessageBrokerView messageBrokerView = MessageBrokerViewRegistry.getInstance().lookup(brokerName); if (messageBrokerView != null) { String destinationName = completionText; Set<? extends ActiveMQDestination> set = messageBrokerView.getQueues(); if (completionText.startsWith("topic:")) { set = messageBrokerView.getTopics(); destinationName = completionText.substring(6); } else if (completionText.startsWith("queue:")) { destinationName = completionText.substring(6); } ArrayList<String> answer = new ArrayList<String>(); for (ActiveMQDestination destination : set) { if (destination.getPhysicalName().startsWith(destinationName)) { answer.add(destination.getPhysicalName()); } } return answer; } return null; } }
@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); } }
@Override public List<String> completeEndpointPath(ComponentConfiguration componentConfiguration, String completionText) { String brokerName = String.valueOf(componentConfiguration.getParameter("brokerName")); MessageBrokerView messageBrokerView = MessageBrokerViewRegistry.getInstance().lookup(brokerName); if (messageBrokerView != null) { String destinationName = completionText; Set<? extends ActiveMQDestination> set = messageBrokerView.getQueues(); if (completionText.startsWith("topic:")) { set = messageBrokerView.getTopics(); destinationName = completionText.substring(6); } else if (completionText.startsWith("queue:")) { destinationName = completionText.substring(6); } ArrayList<String> answer = new ArrayList<String>(); for (ActiveMQDestination destination : set) { if (destination.getPhysicalName().startsWith(destinationName)) { answer.add(destination.getPhysicalName()); } } return answer; } return null; } }
/** * 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; }
/** * @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 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 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; }
/** * @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 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 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; }
/** * @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 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 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; }
/** * 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 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; }
/** * 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); }