ARTEMIS-784 Add new JMX methods and update JMX API
This commit is contained in:
parent
3abfd9f552
commit
74d0a1a818
|
@ -436,7 +436,7 @@ public interface ActiveMQServerControl {
|
||||||
|
|
||||||
@Operation(desc = "delete an address", impact = MBeanOperationInfo.ACTION)
|
@Operation(desc = "delete an address", impact = MBeanOperationInfo.ACTION)
|
||||||
void createAddress(@Parameter(name = "name", desc = "The name of the address") String name,
|
void createAddress(@Parameter(name = "name", desc = "The name of the address") String name,
|
||||||
@Parameter(name = "deliveryMode", desc = "The delivery modes enabled for this address'") Object[] routingTypes) throws Exception;
|
@Parameter(name = "routingType", desc = "Comma separated list of Routing Typles (anycast/multicast)") String routingTypes) throws Exception;
|
||||||
|
|
||||||
@Operation(desc = "delete an address", impact = MBeanOperationInfo.ACTION)
|
@Operation(desc = "delete an address", impact = MBeanOperationInfo.ACTION)
|
||||||
void deleteAddress(@Parameter(name = "name", desc = "The name of the address") String name) throws Exception;
|
void deleteAddress(@Parameter(name = "name", desc = "The name of the address") String name) throws Exception;
|
||||||
|
|
|
@ -20,6 +20,7 @@ import javax.management.ObjectName;
|
||||||
|
|
||||||
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
|
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
|
||||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||||
|
import org.apache.activemq.artemis.core.server.RoutingType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class to build ObjectNames for ActiveMQ Artemis resources.
|
* Helper class to build ObjectNames for ActiveMQ Artemis resources.
|
||||||
|
@ -98,10 +99,20 @@ public final class ObjectNameBuilder {
|
||||||
*
|
*
|
||||||
* @see QueueControl
|
* @see QueueControl
|
||||||
*/
|
*/
|
||||||
public ObjectName getQueueObjectName(final SimpleString address, final SimpleString name) throws Exception {
|
public ObjectName getQueueObjectName(final SimpleString address, final SimpleString name, RoutingType routingType) throws Exception {
|
||||||
return ObjectName.getInstance(String.format("%s:" + getBrokerProperties() + "parentType=%s,parentName=%s," + getObjectType() + "=%s,name=%s", domain, "Address", ObjectName.quote(address.toString()), "Queue", ObjectName.quote(name.toString())));
|
return ObjectName.getInstance(String.format("%s:" + getBrokerProperties() + "parentType=%s,parentName=%s," + getObjectType() + "=%s, routingType=%s,name=%s", domain, "Address", ObjectName.quote(address.toString()), "Queue", routingType.toString(), ObjectName.quote(name.toString())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the ObjectName used by QueueControl.
|
||||||
|
*
|
||||||
|
* @see QueueControl
|
||||||
|
*/
|
||||||
|
public ObjectName getQueueObjectName(final SimpleString address, final SimpleString name) throws Exception {
|
||||||
|
return ObjectName.getInstance(String.format("%s:" + getBrokerProperties() + "parentType=%s,parentName=%s," + getObjectType() + "=%s, routingType=%s,name=%s", domain, "Address", ObjectName.quote(address.toString()), "Queue", ActiveMQDefaultConfiguration.getDefaultRoutingType(), ObjectName.quote(name.toString())));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ObjectName used by DivertControl.
|
* Returns the ObjectName used by DivertControl.
|
||||||
*
|
*
|
||||||
|
@ -165,7 +176,7 @@ public final class ObjectNameBuilder {
|
||||||
* Returns the ObjectName used by JMSQueueControl.
|
* Returns the ObjectName used by JMSQueueControl.
|
||||||
*/
|
*/
|
||||||
public ObjectName getJMSQueueObjectName(final String name) throws Exception {
|
public ObjectName getJMSQueueObjectName(final String name) throws Exception {
|
||||||
return getQueueObjectName(SimpleString.toSimpleString(name), SimpleString.toSimpleString(name));
|
return getQueueObjectName(SimpleString.toSimpleString(name), SimpleString.toSimpleString(name), RoutingType.ANYCAST);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -52,7 +52,6 @@ import org.apache.activemq.artemis.api.core.management.AddressControl;
|
||||||
import org.apache.activemq.artemis.api.core.management.BridgeControl;
|
import org.apache.activemq.artemis.api.core.management.BridgeControl;
|
||||||
import org.apache.activemq.artemis.api.core.management.CoreNotificationType;
|
import org.apache.activemq.artemis.api.core.management.CoreNotificationType;
|
||||||
import org.apache.activemq.artemis.api.core.management.DivertControl;
|
import org.apache.activemq.artemis.api.core.management.DivertControl;
|
||||||
import org.apache.activemq.artemis.api.core.management.Parameter;
|
|
||||||
import org.apache.activemq.artemis.api.core.management.QueueControl;
|
import org.apache.activemq.artemis.api.core.management.QueueControl;
|
||||||
import org.apache.activemq.artemis.core.client.impl.Topology;
|
import org.apache.activemq.artemis.core.client.impl.Topology;
|
||||||
import org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl;
|
import org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl;
|
||||||
|
@ -563,14 +562,13 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createAddress(@Parameter(name = "name", desc = "The name of the address") String name,
|
public void createAddress(String name, String routingTypes) throws Exception {
|
||||||
@Parameter(name = "routingType", desc = "The delivery modes enabled for this address'") Object[] routingTypes) throws Exception {
|
|
||||||
checkStarted();
|
checkStarted();
|
||||||
|
|
||||||
clearIO();
|
clearIO();
|
||||||
try {
|
try {
|
||||||
Set<RoutingType> set = new HashSet<>();
|
Set<RoutingType> set = new HashSet<>();
|
||||||
for (Object routingType : routingTypes) {
|
for (Object routingType : toList(routingTypes)) {
|
||||||
set.add(RoutingType.valueOf(routingType.toString()));
|
set.add(RoutingType.valueOf(routingType.toString()));
|
||||||
}
|
}
|
||||||
server.createAddressInfo(new AddressInfo(new SimpleString(name), set));
|
server.createAddressInfo(new AddressInfo(new SimpleString(name), set));
|
||||||
|
|
|
@ -539,7 +539,8 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
|
||||||
}
|
}
|
||||||
|
|
||||||
if (binding.getType() == BindingType.LOCAL_QUEUE) {
|
if (binding.getType() == BindingType.LOCAL_QUEUE) {
|
||||||
managementService.unregisterQueue(uniqueName, binding.getAddress());
|
Queue queue = (Queue) binding.getBindable();
|
||||||
|
managementService.unregisterQueue(uniqueName, binding.getAddress(), queue.getRoutingType());
|
||||||
} else if (binding.getType() == BindingType.DIVERT) {
|
} else if (binding.getType() == BindingType.DIVERT) {
|
||||||
managementService.unregisterDivert(uniqueName, binding.getAddress());
|
managementService.unregisterDivert(uniqueName, binding.getAddress());
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||||
import org.apache.activemq.artemis.core.server.Divert;
|
import org.apache.activemq.artemis.core.server.Divert;
|
||||||
import org.apache.activemq.artemis.core.server.Queue;
|
import org.apache.activemq.artemis.core.server.Queue;
|
||||||
import org.apache.activemq.artemis.core.server.QueueFactory;
|
import org.apache.activemq.artemis.core.server.QueueFactory;
|
||||||
|
import org.apache.activemq.artemis.core.server.RoutingType;
|
||||||
import org.apache.activemq.artemis.core.server.ServerMessage;
|
import org.apache.activemq.artemis.core.server.ServerMessage;
|
||||||
import org.apache.activemq.artemis.core.server.cluster.Bridge;
|
import org.apache.activemq.artemis.core.server.cluster.Bridge;
|
||||||
import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup;
|
import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup;
|
||||||
|
@ -96,7 +97,7 @@ public interface ManagementService extends NotificationService, ActiveMQComponen
|
||||||
|
|
||||||
void registerQueue(Queue queue, SimpleString address, StorageManager storageManager) throws Exception;
|
void registerQueue(Queue queue, SimpleString address, StorageManager storageManager) throws Exception;
|
||||||
|
|
||||||
void unregisterQueue(SimpleString name, SimpleString address) throws Exception;
|
void unregisterQueue(SimpleString name, SimpleString address, RoutingType routingType) throws Exception;
|
||||||
|
|
||||||
void registerAcceptor(Acceptor acceptor, TransportConfiguration configuration) throws Exception;
|
void registerAcceptor(Acceptor acceptor, TransportConfiguration configuration) throws Exception;
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
|
||||||
import org.apache.activemq.artemis.core.server.Divert;
|
import org.apache.activemq.artemis.core.server.Divert;
|
||||||
import org.apache.activemq.artemis.core.server.Queue;
|
import org.apache.activemq.artemis.core.server.Queue;
|
||||||
import org.apache.activemq.artemis.core.server.QueueFactory;
|
import org.apache.activemq.artemis.core.server.QueueFactory;
|
||||||
|
import org.apache.activemq.artemis.core.server.RoutingType;
|
||||||
import org.apache.activemq.artemis.core.server.ServerMessage;
|
import org.apache.activemq.artemis.core.server.ServerMessage;
|
||||||
import org.apache.activemq.artemis.core.server.cluster.Bridge;
|
import org.apache.activemq.artemis.core.server.cluster.Bridge;
|
||||||
import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup;
|
import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup;
|
||||||
|
@ -241,7 +242,7 @@ public class ManagementServiceImpl implements ManagementService {
|
||||||
queueControl.setMessageCounter(counter);
|
queueControl.setMessageCounter(counter);
|
||||||
messageCounterManager.registerMessageCounter(queue.getName().toString(), counter);
|
messageCounterManager.registerMessageCounter(queue.getName().toString(), counter);
|
||||||
}
|
}
|
||||||
ObjectName objectName = objectNameBuilder.getQueueObjectName(address, queue.getName());
|
ObjectName objectName = objectNameBuilder.getQueueObjectName(address, queue.getName(),queue.getRoutingType());
|
||||||
registerInJMX(objectName, queueControl);
|
registerInJMX(objectName, queueControl);
|
||||||
registerInRegistry(ResourceNames.QUEUE + queue.getName(), queueControl);
|
registerInRegistry(ResourceNames.QUEUE + queue.getName(), queueControl);
|
||||||
|
|
||||||
|
@ -251,8 +252,8 @@ public class ManagementServiceImpl implements ManagementService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void unregisterQueue(final SimpleString name, final SimpleString address) throws Exception {
|
public synchronized void unregisterQueue(final SimpleString name, final SimpleString address, RoutingType routingType) throws Exception {
|
||||||
ObjectName objectName = objectNameBuilder.getQueueObjectName(address, name);
|
ObjectName objectName = objectNameBuilder.getQueueObjectName(address, name, routingType);
|
||||||
unregisterFromJMX(objectName);
|
unregisterFromJMX(objectName);
|
||||||
unregisterFromRegistry(ResourceNames.QUEUE + name);
|
unregisterFromRegistry(ResourceNames.QUEUE + name);
|
||||||
messageCounterManager.unregisterMessageCounter(name.toString());
|
messageCounterManager.unregisterMessageCounter(name.toString());
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||||
import org.apache.activemq.artemis.core.server.Divert;
|
import org.apache.activemq.artemis.core.server.Divert;
|
||||||
import org.apache.activemq.artemis.core.server.Queue;
|
import org.apache.activemq.artemis.core.server.Queue;
|
||||||
import org.apache.activemq.artemis.core.server.QueueFactory;
|
import org.apache.activemq.artemis.core.server.QueueFactory;
|
||||||
|
import org.apache.activemq.artemis.core.server.RoutingType;
|
||||||
import org.apache.activemq.artemis.core.server.ServerMessage;
|
import org.apache.activemq.artemis.core.server.ServerMessage;
|
||||||
import org.apache.activemq.artemis.core.server.cluster.Bridge;
|
import org.apache.activemq.artemis.core.server.cluster.Bridge;
|
||||||
import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup;
|
import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup;
|
||||||
|
@ -261,7 +262,7 @@ public class ClusteredResetMockTest extends ActiveMQTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unregisterQueue(SimpleString name, SimpleString address) throws Exception {
|
public void unregisterQueue(SimpleString name, SimpleString address, RoutingType routingType) throws Exception {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -268,7 +268,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
|
||||||
|
|
||||||
serverControl.createQueue(address.toString(), RoutingType.ANYCAST.toString(), name.toString(), null, durable, maxConsumers, deleteOnNoConsumers, autoCreateAddress);
|
serverControl.createQueue(address.toString(), RoutingType.ANYCAST.toString(), name.toString(), null, durable, maxConsumers, deleteOnNoConsumers, autoCreateAddress);
|
||||||
|
|
||||||
checkResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name));
|
checkResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name, RoutingType.ANYCAST));
|
||||||
QueueControl queueControl = ManagementControlHelper.createQueueControl(address, name, mbeanServer);
|
QueueControl queueControl = ManagementControlHelper.createQueueControl(address, name, mbeanServer);
|
||||||
Assert.assertEquals(address.toString(), queueControl.getAddress());
|
Assert.assertEquals(address.toString(), queueControl.getAddress());
|
||||||
Assert.assertEquals(name.toString(), queueControl.getName());
|
Assert.assertEquals(name.toString(), queueControl.getName());
|
||||||
|
|
|
@ -566,7 +566,7 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createAddress(@Parameter(name = "name", desc = "The name of the address") String name,
|
public void createAddress(@Parameter(name = "name", desc = "The name of the address") String name,
|
||||||
@Parameter(name = "routingType", desc = "The delivery modes enabled for this address'") Object[] routingTypes) throws Exception {
|
@Parameter(name = "routingType", desc = "The delivery modes enabled for this address'") String routingTypes) throws Exception {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ import javax.management.MBeanServer;
|
||||||
import javax.management.MBeanServerInvocationHandler;
|
import javax.management.MBeanServerInvocationHandler;
|
||||||
import javax.management.ObjectName;
|
import javax.management.ObjectName;
|
||||||
|
|
||||||
|
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
|
||||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||||
import org.apache.activemq.artemis.api.core.management.AcceptorControl;
|
import org.apache.activemq.artemis.api.core.management.AcceptorControl;
|
||||||
import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl;
|
import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl;
|
||||||
|
@ -69,7 +70,7 @@ public class ManagementControlHelper {
|
||||||
public static QueueControl createQueueControl(final SimpleString address,
|
public static QueueControl createQueueControl(final SimpleString address,
|
||||||
final SimpleString name,
|
final SimpleString name,
|
||||||
final MBeanServer mbeanServer) throws Exception {
|
final MBeanServer mbeanServer) throws Exception {
|
||||||
return (QueueControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name), QueueControl.class, mbeanServer);
|
return (QueueControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name, ActiveMQDefaultConfiguration.getDefaultRoutingType()), QueueControl.class, mbeanServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AddressControl createAddressControl(final SimpleString address,
|
public static AddressControl createAddressControl(final SimpleString address,
|
||||||
|
|
|
@ -55,6 +55,7 @@ import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
|
||||||
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory;
|
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory;
|
||||||
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory;
|
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory;
|
||||||
import org.apache.activemq.artemis.core.server.ActiveMQServers;
|
import org.apache.activemq.artemis.core.server.ActiveMQServers;
|
||||||
|
import org.apache.activemq.artemis.core.server.RoutingType;
|
||||||
import org.apache.activemq.artemis.jms.bridge.ConnectionFactoryFactory;
|
import org.apache.activemq.artemis.jms.bridge.ConnectionFactoryFactory;
|
||||||
import org.apache.activemq.artemis.jms.bridge.DestinationFactory;
|
import org.apache.activemq.artemis.jms.bridge.DestinationFactory;
|
||||||
import org.apache.activemq.artemis.jms.bridge.QualityOfServiceMode;
|
import org.apache.activemq.artemis.jms.bridge.QualityOfServiceMode;
|
||||||
|
@ -470,7 +471,7 @@ public class JMSBridgeImplTest extends ActiveMQTestBase {
|
||||||
|
|
||||||
sourceConn.close();
|
sourceConn.close();
|
||||||
SimpleString add = new SimpleString(JMSBridgeImplTest.SOURCE);
|
SimpleString add = new SimpleString(JMSBridgeImplTest.SOURCE);
|
||||||
QueueControl jmsQueueControl = MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(), ObjectNameBuilder.DEFAULT.getQueueObjectName(add, add), QueueControl.class, false);
|
QueueControl jmsQueueControl = MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(), ObjectNameBuilder.DEFAULT.getQueueObjectName(add, add, RoutingType.ANYCAST), QueueControl.class, false);
|
||||||
assertNotEquals(jmsQueueControl.getDeliveringCount(), numMessages);
|
assertNotEquals(jmsQueueControl.getDeliveringCount(), numMessages);
|
||||||
|
|
||||||
bridge.stop();
|
bridge.stop();
|
||||||
|
|
Loading…
Reference in New Issue