mirror of https://github.com/apache/activemq.git
code fix and test fix for: https://issues.apache.org/jira/browse/AMQ-4225
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:
parent
8e9896825f
commit
b2de5f310f
|
@ -83,9 +83,17 @@ public class MBeanNetworkListener implements NetworkBridgeListener {
|
||||||
|
|
||||||
protected ObjectName createNetworkBridgeObjectName(NetworkBridge bridge) throws MalformedObjectNameException {
|
protected ObjectName createNetworkBridgeObjectName(NetworkBridge bridge) throws MalformedObjectNameException {
|
||||||
Map<String, String> map = new HashMap<String, String>(connectorName.getKeyPropertyList());
|
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="
|
StringBuilder objectNameStr = new StringBuilder();
|
||||||
+ JMXSupport.encodeObjectNamePart(JMXSupport.encodeObjectNamePart(bridge.getRemoteAddress())));
|
|
||||||
|
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) {
|
public void setCreatedByDuplex(boolean createdByDuplex) {
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.network;
|
package org.apache.activemq.network;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -27,10 +30,6 @@ import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
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.Connection;
|
||||||
import javax.jms.ConnectionFactory;
|
import javax.jms.ConnectionFactory;
|
||||||
import javax.jms.JMSException;
|
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.IntrospectionSupport;
|
||||||
import org.apache.activemq.util.JMXSupport;
|
import org.apache.activemq.util.JMXSupport;
|
||||||
import org.apache.activemq.util.Wait;
|
import org.apache.activemq.util.Wait;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class FailoverStaticNetworkTest {
|
public class FailoverStaticNetworkTest {
|
||||||
protected static final Logger LOG = LoggerFactory.getLogger(FailoverStaticNetworkTest.class);
|
protected static final Logger LOG = LoggerFactory.getLogger(FailoverStaticNetworkTest.class);
|
||||||
|
@ -192,8 +191,8 @@ public class FailoverStaticNetworkTest {
|
||||||
private Set<String> getNetworkBridgeMBeanName(BrokerService brokerB) throws Exception {
|
private Set<String> getNetworkBridgeMBeanName(BrokerService brokerB) throws Exception {
|
||||||
Set<String> names = new HashSet<String>();
|
Set<String> names = new HashSet<String>();
|
||||||
for (ObjectName objectName : brokerB.getManagementContext().queryNames(null, null)) {
|
for (ObjectName objectName : brokerB.getManagementContext().queryNames(null, null)) {
|
||||||
if ("NetworkBridge".equals(objectName.getKeyProperty("Type"))) {
|
if ("NetworkBridge".equals(objectName.getKeyProperty("service"))) {
|
||||||
names.add(objectName.getKeyProperty("Name"));
|
names.add(objectName.getKeyProperty("networkBridgeName"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return names;
|
return names;
|
||||||
|
@ -210,6 +209,7 @@ public class FailoverStaticNetworkTest {
|
||||||
brokerA1 = slave;
|
brokerA1 = slave;
|
||||||
ExecutorService executor = Executors.newCachedThreadPool();
|
ExecutorService executor = Executors.newCachedThreadPool();
|
||||||
executor.execute(new Runnable() {
|
executor.execute(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
slave.start();
|
slave.start();
|
||||||
|
@ -253,6 +253,7 @@ public class FailoverStaticNetworkTest {
|
||||||
brokerA1 = slave;
|
brokerA1 = slave;
|
||||||
ExecutorService executor = Executors.newCachedThreadPool();
|
ExecutorService executor = Executors.newCachedThreadPool();
|
||||||
executor.execute(new Runnable() {
|
executor.execute(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
slave.start();
|
slave.start();
|
||||||
|
@ -430,6 +431,7 @@ public class FailoverStaticNetworkTest {
|
||||||
sendMessageTo(destination, to);
|
sendMessageTo(destination, to);
|
||||||
|
|
||||||
boolean gotMessage = Wait.waitFor(new Wait.Condition() {
|
boolean gotMessage = Wait.waitFor(new Wait.Condition() {
|
||||||
|
@Override
|
||||||
public boolean isSatisified() throws Exception {
|
public boolean isSatisified() throws Exception {
|
||||||
Message message = consumer.receive(5000);
|
Message message = consumer.receive(5000);
|
||||||
LOG.info("from: " + from.getBrokerObjectName().getKeyProperty("BrokerName") + ", received: " + message);
|
LOG.info("from: " + from.getBrokerObjectName().getKeyProperty("BrokerName") + ", received: " + message);
|
||||||
|
@ -453,7 +455,7 @@ public class FailoverStaticNetworkTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ConnectionFactory createConnectionFactory(final BrokerService broker) throws Exception {
|
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);
|
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
|
||||||
connectionFactory.setOptimizedMessageDispatch(true);
|
connectionFactory.setOptimizedMessageDispatch(true);
|
||||||
connectionFactory.setDispatchAsync(false);
|
connectionFactory.setDispatchAsync(false);
|
||||||
|
|
Loading…
Reference in New Issue