This closes #3149
This commit is contained in:
commit
d3d7d2264d
|
@ -74,7 +74,13 @@ public interface AddressControl {
|
|||
/**
|
||||
* Returns the names of the queues bound to this address.
|
||||
*/
|
||||
@Attribute(desc = "names of the queue(s) bound to this address")
|
||||
@Attribute(desc = "names of the remote queue(s) bound to this address")
|
||||
String[] getRemoteQueueNames() throws Exception;
|
||||
|
||||
/**
|
||||
* Returns the names of the queues bound to this address.
|
||||
*/
|
||||
@Attribute(desc = "names of the local queue(s) bound to this address")
|
||||
String[] getQueueNames() throws Exception;
|
||||
|
||||
/**
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.apache.activemq.artemis.core.security.Role;
|
|||
import org.apache.activemq.artemis.core.security.SecurityStore;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
|
||||
import org.apache.activemq.artemis.core.server.cluster.RemoteQueueBinding;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
import org.apache.activemq.artemis.core.server.management.ManagementService;
|
||||
import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
|
||||
|
@ -130,10 +131,19 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getRemoteQueueNames() throws Exception {
|
||||
return getQueueNames(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getQueueNames() throws Exception {
|
||||
return getQueueNames(true);
|
||||
}
|
||||
|
||||
private String[] getQueueNames(boolean local) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getQueueNames(this.addressInfo);
|
||||
AuditLogger.getQueueNames(this.addressInfo, local);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
|
@ -141,7 +151,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
if (bindings != null) {
|
||||
List<String> queueNames = new ArrayList<>();
|
||||
for (Binding binding : bindings.getBindings()) {
|
||||
if (binding instanceof QueueBinding) {
|
||||
if ((local && binding.isLocal()) || (!local && binding instanceof RemoteQueueBinding)) {
|
||||
queueNames.add(binding.getUniqueName().toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,9 @@ import org.apache.activemq.artemis.core.config.Configuration;
|
|||
import org.apache.activemq.artemis.core.security.CheckType;
|
||||
import org.apache.activemq.artemis.core.security.Role;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.cluster.RemoteQueueBinding;
|
||||
import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
|
||||
import org.apache.activemq.artemis.core.server.cluster.impl.RemoteQueueBindingImpl;
|
||||
import org.apache.activemq.artemis.core.server.impl.QueueImpl;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||
import org.apache.activemq.artemis.tests.util.Wait;
|
||||
|
@ -106,6 +109,10 @@ public class AddressControlTest extends ManagementTestBase {
|
|||
|
||||
session.createQueue(new QueueConfiguration(queue).setAddress(address));
|
||||
|
||||
// add a fake RemoteQueueBinding to simulate being in a cluster; we don't want this binding to be returned by getQueueNames()
|
||||
RemoteQueueBinding binding = new RemoteQueueBindingImpl(server.getStorageManager().generateID(), address, RandomUtil.randomSimpleString(), RandomUtil.randomSimpleString(), RandomUtil.randomLong(), null, null, RandomUtil.randomSimpleString(), RandomUtil.randomInt() + 1, MessageLoadBalancingType.OFF);
|
||||
server.getPostOffice().addBinding(binding);
|
||||
|
||||
AddressControl addressControl = createManagementControl(address);
|
||||
String[] queueNames = addressControl.getQueueNames();
|
||||
Assert.assertEquals(1, queueNames.length);
|
||||
|
@ -124,6 +131,23 @@ public class AddressControlTest extends ManagementTestBase {
|
|||
session.deleteQueue(anotherQueue);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRemoteQueueNames() throws Exception {
|
||||
SimpleString address = RandomUtil.randomSimpleString();
|
||||
SimpleString queue = RandomUtil.randomSimpleString();
|
||||
|
||||
session.createAddress(address, RoutingType.MULTICAST, false);
|
||||
|
||||
// add a fake RemoteQueueBinding to simulate being in a cluster; this should be returned by getRemoteQueueNames()
|
||||
RemoteQueueBinding binding = new RemoteQueueBindingImpl(server.getStorageManager().generateID(), address, queue, RandomUtil.randomSimpleString(), RandomUtil.randomLong(), null, null, RandomUtil.randomSimpleString(), RandomUtil.randomInt() + 1, MessageLoadBalancingType.OFF);
|
||||
server.getPostOffice().addBinding(binding);
|
||||
|
||||
AddressControl addressControl = createManagementControl(address);
|
||||
String[] queueNames = addressControl.getRemoteQueueNames();
|
||||
Assert.assertEquals(1, queueNames.length);
|
||||
Assert.assertEquals(queue.toString(), queueNames[0]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBindingNames() throws Exception {
|
||||
SimpleString address = RandomUtil.randomSimpleString();
|
||||
|
|
|
@ -73,6 +73,11 @@ public class AddressControlUsingCoreTest extends AddressControlTest {
|
|||
return (long) proxy.retrieveAttributeValue("numberOfMessages");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getRemoteQueueNames() throws Exception {
|
||||
return (String[]) proxy.retrieveAttributeValue("remoteQueueNames", String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getQueueNames() throws Exception {
|
||||
return (String[]) proxy.retrieveAttributeValue("queueNames", String.class);
|
||||
|
|
Loading…
Reference in New Issue