NetworkBridge MBeans weren't getting registered because of changes in the Broker MBean naming.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1429064 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2013-01-04 19:53:47 +00:00
parent 8e9896825f
commit b2de5f310f
2 changed files with 37 additions and 27 deletions

View File

@ -83,9 +83,17 @@ public class MBeanNetworkListener implements NetworkBridgeListener {
protected ObjectName createNetworkBridgeObjectName(NetworkBridge bridge) throws MalformedObjectNameException {
Map<String, String> map = new HashMap<String, String>(connectorName.getKeyPropertyList());
return new ObjectName(connectorName.getDomain() + ":" + "BrokerName=" + JMXSupport.encodeObjectNamePart((String) map.get("BrokerName")) + "," + "Type=NetworkBridge,"
+ "NetworkConnectorName=" + JMXSupport.encodeObjectNamePart((String)map.get("NetworkConnectorName")) + "," + "Name="
+ JMXSupport.encodeObjectNamePart(JMXSupport.encodeObjectNamePart(bridge.getRemoteAddress())));
StringBuilder objectNameStr = new StringBuilder();
objectNameStr.append(connectorName.getDomain()).append(":");
objectNameStr.append("type=Broker").append(",");
objectNameStr.append("brokerName=" + JMXSupport.encodeObjectNamePart(map.get("brokerName"))).append(",");
objectNameStr.append("service=NetworkBridge").append(",");
objectNameStr.append("networkConnectorName=" + JMXSupport.encodeObjectNamePart(map.get("networkConnectorName"))).append(",");
objectNameStr.append("networkBridgeName=" + JMXSupport.encodeObjectNamePart(bridge.getRemoteAddress()));
return new ObjectName(objectNameStr.toString());
}
public void setCreatedByDuplex(boolean createdByDuplex) {

View File

@ -16,6 +16,9 @@
*/
package org.apache.activemq.network;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
@ -27,10 +30,6 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
@ -51,11 +50,11 @@ import org.apache.activemq.transport.tcp.SslBrokerServiceTest;
import org.apache.activemq.util.IntrospectionSupport;
import org.apache.activemq.util.JMXSupport;
import org.apache.activemq.util.Wait;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class FailoverStaticNetworkTest {
protected static final Logger LOG = LoggerFactory.getLogger(FailoverStaticNetworkTest.class);
@ -192,8 +191,8 @@ public class FailoverStaticNetworkTest {
private Set<String> getNetworkBridgeMBeanName(BrokerService brokerB) throws Exception {
Set<String> names = new HashSet<String>();
for (ObjectName objectName : brokerB.getManagementContext().queryNames(null, null)) {
if ("NetworkBridge".equals(objectName.getKeyProperty("Type"))) {
names.add(objectName.getKeyProperty("Name"));
if ("NetworkBridge".equals(objectName.getKeyProperty("service"))) {
names.add(objectName.getKeyProperty("networkBridgeName"));
}
}
return names;
@ -210,6 +209,7 @@ public class FailoverStaticNetworkTest {
brokerA1 = slave;
ExecutorService executor = Executors.newCachedThreadPool();
executor.execute(new Runnable() {
@Override
public void run() {
try {
slave.start();
@ -253,6 +253,7 @@ public class FailoverStaticNetworkTest {
brokerA1 = slave;
ExecutorService executor = Executors.newCachedThreadPool();
executor.execute(new Runnable() {
@Override
public void run() {
try {
slave.start();
@ -430,6 +431,7 @@ public class FailoverStaticNetworkTest {
sendMessageTo(destination, to);
boolean gotMessage = Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
Message message = consumer.receive(5000);
LOG.info("from: " + from.getBrokerObjectName().getKeyProperty("BrokerName") + ", received: " + message);
@ -453,7 +455,7 @@ public class FailoverStaticNetworkTest {
}
protected ConnectionFactory createConnectionFactory(final BrokerService broker) throws Exception {
String url = ((TransportConnector) broker.getTransportConnectors().get(0)).getServer().getConnectURI().toString();
String url = broker.getTransportConnectors().get(0).getServer().getConnectURI().toString();
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
connectionFactory.setOptimizedMessageDispatch(true);
connectionFactory.setDispatchAsync(false);