This closes #1149
This commit is contained in:
commit
9df74f347b
|
@ -395,6 +395,12 @@ public interface ActiveMQServerControl {
|
|||
@Attribute(desc = "names of the queues created on this server")
|
||||
String[] getQueueNames();
|
||||
|
||||
/**
|
||||
* Returns the names of the queues created on this server with the given routing-type.
|
||||
*/
|
||||
@Attribute(desc = "names of the queues created on this server with the given routing-type (i.e. ANYCAST or MULTICAST)")
|
||||
String[] getQueueNames(String routingType);
|
||||
|
||||
/**
|
||||
* Returns the uptime of this server.
|
||||
*/
|
||||
|
|
|
@ -59,8 +59,8 @@ public interface QueueControl {
|
|||
/**
|
||||
* The routing type of this queue.
|
||||
*/
|
||||
@Attribute(desc = "The routing type of this queue")
|
||||
byte getRoutingType() throws Exception;
|
||||
@Attribute(desc = "routing type of this queue")
|
||||
String getRoutingType();
|
||||
|
||||
/**
|
||||
* Returns the filter associated with this queue.
|
||||
|
|
|
@ -782,18 +782,28 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
|
|||
|
||||
@Override
|
||||
public String[] getQueueNames() {
|
||||
return getQueueNames(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getQueueNames(String routingType) {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
try {
|
||||
Object[] queues = server.getManagementService().getResources(QueueControl.class);
|
||||
String[] names = new String[queues.length];
|
||||
for (int i = 0; i < queues.length; i++) {
|
||||
QueueControl queue = (QueueControl) queues[i];
|
||||
names[i] = queue.getName();
|
||||
Object[] queueControls = server.getManagementService().getResources(QueueControl.class);
|
||||
List<String> names = new ArrayList<>();
|
||||
for (int i = 0; i < queueControls.length; i++) {
|
||||
QueueControl queueControl = (QueueControl) queueControls[i];
|
||||
if (routingType != null && queueControl.getRoutingType().equals(routingType.toUpperCase())) {
|
||||
names.add(queueControl.getName());
|
||||
} else if (routingType == null) {
|
||||
names.add(queueControl.getName());
|
||||
}
|
||||
}
|
||||
|
||||
return names;
|
||||
String[] result = new String[names.size()];
|
||||
return names.toArray(result);
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
|
|
|
@ -176,12 +176,12 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public byte getRoutingType() throws Exception {
|
||||
public String getRoutingType() {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
try {
|
||||
return queue.getRoutingType().getType();
|
||||
return queue.getRoutingType().toString();
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
|
|
|
@ -392,6 +392,34 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
|
|||
Assert.assertFalse(ActiveMQServerControlTest.contains(name.toString(), serverControl.getQueueNames()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetQueueNamesWithRoutingType() throws Exception {
|
||||
SimpleString address = RandomUtil.randomSimpleString();
|
||||
SimpleString anycastName = RandomUtil.randomSimpleString();
|
||||
SimpleString multicastName = RandomUtil.randomSimpleString();
|
||||
|
||||
ActiveMQServerControl serverControl = createManagementControl();
|
||||
|
||||
// due to replication, there can be another queue created for replicating
|
||||
// management operations
|
||||
|
||||
Assert.assertFalse(ActiveMQServerControlTest.contains(anycastName.toString(), serverControl.getQueueNames()));
|
||||
Assert.assertFalse(ActiveMQServerControlTest.contains(multicastName.toString(), serverControl.getQueueNames()));
|
||||
|
||||
serverControl.createQueue(address.toString(), RoutingType.ANYCAST.toString(), anycastName.toString(), null, true, -1, false, true);
|
||||
Assert.assertTrue(ActiveMQServerControlTest.contains(anycastName.toString(), serverControl.getQueueNames(RoutingType.ANYCAST.toString())));
|
||||
Assert.assertFalse(ActiveMQServerControlTest.contains(anycastName.toString(), serverControl.getQueueNames(RoutingType.MULTICAST.toString())));
|
||||
|
||||
serverControl.createQueue(address.toString(), RoutingType.MULTICAST.toString(), multicastName.toString(), null, true, -1, false, true);
|
||||
Assert.assertTrue(ActiveMQServerControlTest.contains(multicastName.toString(), serverControl.getQueueNames(RoutingType.MULTICAST.toString())));
|
||||
Assert.assertFalse(ActiveMQServerControlTest.contains(multicastName.toString(), serverControl.getQueueNames(RoutingType.ANYCAST.toString())));
|
||||
|
||||
serverControl.destroyQueue(anycastName.toString());
|
||||
serverControl.destroyQueue(multicastName.toString());
|
||||
Assert.assertFalse(ActiveMQServerControlTest.contains(anycastName.toString(), serverControl.getQueueNames()));
|
||||
Assert.assertFalse(ActiveMQServerControlTest.contains(multicastName.toString(), serverControl.getQueueNames()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAddressNames() throws Exception {
|
||||
SimpleString address = RandomUtil.randomSimpleString();
|
||||
|
|
|
@ -260,6 +260,17 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
|
|||
return ActiveMQServerControlUsingCoreTest.toStringArray((Object[]) proxy.retrieveAttributeValue("queueNames", String.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getQueueNames(String routingType) {
|
||||
try {
|
||||
return (String[]) proxy.invokeOperation("getQueueNames", routingType);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUptime() {
|
||||
return null;
|
||||
|
|
|
@ -172,8 +172,8 @@ public class QueueControlUsingCoreTest extends QueueControlTest {
|
|||
}
|
||||
|
||||
@Override
|
||||
public byte getRoutingType() throws Exception {
|
||||
return (byte) proxy.retrieveAttributeValue("routingType");
|
||||
public String getRoutingType() {
|
||||
return (String) proxy.retrieveAttributeValue("routingType");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue