Skip to content

Commit

Permalink
ARTEMIS-4498 Making queues always manageable
Browse files Browse the repository at this point in the history
  • Loading branch information
clebertsuconic committed Apr 11, 2024
1 parent 7702b39 commit 162c4f6
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ private Queue installMirrorController(AMQPMirrorBrokerConnectionElement replicaC
}

try {
server.registerQueueOnManagement(mirrorControlQueue, true);
server.registerQueueOnManagement(mirrorControlQueue);
} catch (Throwable ignored) {
logger.debug(ignored.getMessage(), ignored);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ public boolean test(QueueControl queue) {
return matches(queue.getScheduledCount());
case USER:
return matches(queue.getUser());
case INTERNAL_QUEUE:
return matches(queue.isInternalQueue());
default:
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ Queue updateQueue(String name,
*/
void autoRemoveAddressInfo(SimpleString address, SecurityAuth auth) throws Exception;

void registerQueueOnManagement(Queue queue, boolean registerInternal) throws Exception;
void registerQueueOnManagement(Queue queue) throws Exception;

/**
* Remove an {@code AddressInfo} from the broker.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4000,8 +4000,8 @@ public void autoRemoveAddressInfo(SimpleString address, SecurityAuth auth) throw

/** Register a queue on the management registry */
@Override
public void registerQueueOnManagement(Queue queue, boolean registerInternal) throws Exception {
managementService.registerQueue(queue, queue.getAddress(), storageManager, registerInternal);
public void registerQueueOnManagement(Queue queue) throws Exception {
managementService.registerQueue(queue, queue.getAddress(), storageManager);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ ActiveMQServerControlImpl registerServer(PostOffice postOffice,

void registerQueue(Queue queue, SimpleString address, StorageManager storageManager) throws Exception;

void registerQueue(Queue queue, SimpleString address, StorageManager storageManager, boolean forceInternal) throws Exception;

void unregisterQueue(SimpleString name, SimpleString address, RoutingType routingType) throws Exception;

void registerAcceptor(Acceptor acceptor, TransportConfiguration configuration) throws Exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,18 +298,6 @@ public synchronized void unregisterAddress(final SimpleString address) throws Ex
public synchronized void registerQueue(final Queue queue,
final AddressInfo addressInfo,
final StorageManager storageManager) throws Exception {
registerQueue(queue, addressInfo, storageManager, false);
}

private synchronized void registerQueue(final Queue queue,
final AddressInfo addressInfo,
final StorageManager storageManager,
boolean forceInternal) throws Exception {

if (!forceInternal && (addressInfo.isInternal() || queue.isInternalQueue())) {
logger.debug("won't register internal queue: {}", queue);
return;
}

QueueControlImpl queueControl = new QueueControlImpl(queue, addressInfo.getName().toString(), messagingServer, storageManager, securityStore, addressSettingsRepository);
if (messageCounterManager != null) {
Expand All @@ -332,14 +320,6 @@ public synchronized void registerQueue(final Queue queue,
registerQueue(queue, new AddressInfo(address), storageManager);
}

@Override
public synchronized void registerQueue(final Queue queue,
final SimpleString address,
final StorageManager storageManager,
final boolean forceInternal) throws Exception {
registerQueue(queue, new AddressInfo(address), storageManager, forceInternal);
}

@Override
public synchronized void unregisterQueue(final SimpleString name, final SimpleString address, RoutingType routingType) throws Exception {
ObjectName objectName = objectNameBuilder.getQueueObjectName(address, name, routingType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,6 @@ public void registerQueue(Queue queue, SimpleString address, StorageManager stor

}

@Override
public void registerQueue(Queue queue, SimpleString address, StorageManager storageManager, boolean forceInternal) throws Exception {

}

@Override
public void unregisterQueue(SimpleString name, SimpleString address, RoutingType routingType) throws Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ import org.apache.activemq.artemis.api.core.management.QueueControl;
Object[] queueControls = server.getJMSServerManager().getActiveMQServer().getManagementService().getResources(QueueControl.class);
for (Object o : queueControls) {
QueueControl c = (QueueControl) o;
if (c.isInternalQueue()) {
continue;
}

GroovyRun.assertTrue(c.getPersistentSize() > 0);
GroovyRun.assertTrue(c.getDurablePersistentSize() > 0);
GroovyRun.assertEquals(33l, c.getMessageCount());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3479,7 +3479,7 @@ public void testListQueues() throws Exception {
Assert.assertTrue(array.getJsonObject(1).getString("name").contains("my_queue"));

//test with an empty filter
filterString = createJsonFilter("", "", "");
filterString = createJsonFilter("internalQueue", "NOT_CONTAINS", "true");

queuesAsJsonString = serverControl.listQueues(filterString, 1, 50);

Expand Down Expand Up @@ -3727,8 +3727,8 @@ public void testListQueuesNumericFilter() throws Exception {

queuesAsJsonObject = JsonUtil.readJsonObject(queuesAsJsonString);
array = (JsonArray) queuesAsJsonObject.get("data");
Assert.assertEquals("number of queues returned from LESS_THAN query", 1, array.size());
Assert.assertEquals("correct queue returned from query", queueName4.toString(), array.getJsonObject(0).getString("name"));
Assert.assertEquals("number of queues returned from LESS_THAN query", 2, array.size());
Assert.assertEquals("correct queue returned from query", queueName4.toString(), array.getJsonObject(1).getString("name"));

//test with GREATER_THAN returns 2 queue
filterString = createJsonFilter("CONSUMER_COUNT", "GREATER_THAN", "2");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void testInternalQueue() throws Exception {
server.start();
Queue queue = server.locateQueue(getName());
Assert.assertTrue(queue.isInternalQueue());
Assert.assertNull(server.getManagementService().getResource(ResourceNames.QUEUE + getName()));
Assert.assertNotNull(server.getManagementService().getResource(ResourceNames.QUEUE + getName()));

server.stop();
}
Expand Down

0 comments on commit 162c4f6

Please sign in to comment.