mirror of https://github.com/apache/activemq.git
resolve intermiittent failures related to broker start and async mbean registration
This commit is contained in:
parent
4648dbee41
commit
2a62b74232
|
@ -23,6 +23,7 @@ import java.net.URL;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import javax.jms.BytesMessage;
|
import javax.jms.BytesMessage;
|
||||||
import javax.jms.Connection;
|
import javax.jms.Connection;
|
||||||
|
@ -60,6 +61,7 @@ import org.apache.activemq.command.ActiveMQQueue;
|
||||||
import org.apache.activemq.command.ActiveMQTempQueue;
|
import org.apache.activemq.command.ActiveMQTempQueue;
|
||||||
import org.apache.activemq.util.JMXSupport;
|
import org.apache.activemq.util.JMXSupport;
|
||||||
import org.apache.activemq.util.URISupport;
|
import org.apache.activemq.util.URISupport;
|
||||||
|
import org.apache.activemq.util.Wait;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -735,13 +737,20 @@ public class MBeanTest extends EmbeddedBrokerTestSupport {
|
||||||
assertEquals("broker Topic Producer count", 0, broker.getTopicProducers().length);
|
assertEquals("broker Topic Producer count", 0, broker.getTopicProducers().length);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ObjectName assertRegisteredObjectName(String name) throws MalformedObjectNameException, NullPointerException {
|
protected ObjectName assertRegisteredObjectName(String name) throws MalformedObjectNameException, Exception {
|
||||||
ObjectName objectName = new ObjectName(name);
|
final ObjectName objectName = new ObjectName(name);
|
||||||
if (mbeanServer.isRegistered(objectName)) {
|
final AtomicBoolean result = new AtomicBoolean(false);
|
||||||
echo("Bean Registered: " + objectName);
|
assertTrue("Bean registered: " + objectName, Wait.waitFor(new Wait.Condition() {
|
||||||
} else {
|
@Override
|
||||||
fail("Could not find MBean!: " + objectName);
|
public boolean isSatisified() throws Exception {
|
||||||
}
|
try {
|
||||||
|
result.set(mbeanServer.isRegistered(objectName));
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
LOG.debug(ignored.toString());
|
||||||
|
}
|
||||||
|
return result.get();
|
||||||
|
}
|
||||||
|
}));
|
||||||
return objectName;
|
return objectName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue