diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/BrokerRegistry.java b/activemq-core/src/main/java/org/apache/activemq/broker/BrokerRegistry.java index 5754aa53d6..111ec10063 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/BrokerRegistry.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/BrokerRegistry.java @@ -18,6 +18,7 @@ package org.apache.activemq.broker; import java.util.HashMap; +import java.util.Iterator; /** * @@ -39,7 +40,20 @@ public class BrokerRegistry { return (BrokerService)brokers.get(brokerName); } } - + + /** + * Returns the first registered broker found + */ + public BrokerService findFirst() { + synchronized(mutex) { + Iterator iter = brokers.values().iterator(); + while (iter.hasNext()) { + return (BrokerService) iter.next(); + } + return null; + } + } + public void bind(String brokerName, BrokerService broker) { synchronized(mutex) { brokers.put(brokerName, broker);