use of org.apache.activemq.artemis.api.core.management.QueueControl in project activemq-artemis by apache.
the class LocalTestServer method removeAllMessages.
@Override
public void removeAllMessages(final String queueName) throws Exception {
QueueControl queue = (QueueControl) getActiveMQServer().getManagementService().getResource(ResourceNames.QUEUE + queueName);
queue.removeMessages(null);
}
use of org.apache.activemq.artemis.api.core.management.QueueControl in project activemq-artemis by apache.
the class BridgeTestBase method checkEmpty.
public boolean checkEmpty(final Queue queue, final int index) throws Exception {
ManagementService managementService = server0.getManagementService();
if (index == 1) {
managementService = server1.getManagementService();
}
QueueControl queueControl = (QueueControl) managementService.getResource(ResourceNames.QUEUE + queue.getQueueName());
// server may be closed
if (queueControl != null) {
queueControl.flushExecutor();
Long messageCount = queueControl.getMessageCount();
if (messageCount > 0) {
queueControl.removeMessages(null);
}
}
return true;
}
use of org.apache.activemq.artemis.api.core.management.QueueControl in project wildfly by wildfly.
the class JMSTopicControlHandler method listSubscribersInfosAsJSON.
private String listSubscribersInfosAsJSON(final DurabilityType durability, AddressControl addressControl, ManagementService managementService) {
javax.json.JsonArrayBuilder array = JsonLoader.createArrayBuilder();
try {
List<QueueControl> queues = JMSTopicReadAttributeHandler.getQueues(durability, addressControl, managementService);
for (QueueControl queue : queues) {
String clientID = null;
String subName = null;
if (queue.isDurable() && RoutingType.MULTICAST.toString().equals(queue.getRoutingType())) {
Pair<String, String> pair = ActiveMQDestination.decomposeQueueNameForDurableSubscription(queue.getName());
clientID = pair.getA();
subName = pair.getB();
} else if (RoutingType.MULTICAST.toString().equals(queue.getRoutingType())) {
// in the case of heirarchical topics the queue name will not follow the <part>.<part> pattern of normal
// durable subscribers so skip decomposing the name for the client ID and subscription name and just
// hard-code it
clientID = "ActiveMQ";
subName = "ActiveMQ";
}
String filter = queue.getFilter() != null ? queue.getFilter() : null;
JsonObject info = JsonLoader.createObjectBuilder().add("queueName", queue.getName()).add("clientID", nullSafe(clientID)).add("selector", nullSafe(filter)).add("name", nullSafe(subName)).add("durable", queue.isDurable()).add("messageCount", queue.getMessageCount()).add("deliveringCount", queue.getDeliveringCount()).add("consumers", queue.listConsumersAsJSON()).build();
array.add(info);
}
} catch (Exception e) {
rethrow(e);
}
return array.build().toString();
}
use of org.apache.activemq.artemis.api.core.management.QueueControl in project wildfly by wildfly.
the class JMSTopicControlHandler method dropDurableSubscription.
private void dropDurableSubscription(final String clientID, final String subscriptionName, ManagementService managementService) throws Exception {
SimpleString queueName = ActiveMQDestination.createQueueNameForSubscription(true, clientID, subscriptionName);
QueueControl coreQueueControl = (QueueControl) managementService.getResource(ResourceNames.QUEUE + queueName);
if (coreQueueControl == null) {
throw new IllegalArgumentException("No subscriptions with name " + queueName + " for clientID " + clientID);
}
ActiveMQServerControl serverControl = (ActiveMQServerControl) managementService.getResource(ResourceNames.BROKER);
serverControl.destroyQueue(queueName.toString(), true);
}
use of org.apache.activemq.artemis.api.core.management.QueueControl in project wildfly by wildfly.
the class JMSTopicReadAttributeHandler method getMessageCount.
private int getMessageCount(final DurabilityType durability, AddressControl addressControl, ManagementService managementService) {
List<QueueControl> queues = getQueues(durability, addressControl, managementService);
int count = 0;
for (QueueControl queue : queues) {
count += queue.getMessageCount();
}
return count;
}
Aggregations