use of org.apache.activemq.artemis.api.core.management.QueueControl in project activemq-artemis by apache.
the class AddressControlImpl method getQueues.
private List<QueueControl> getQueues(final DurabilityType durability) {
try {
List<QueueControl> matchingQueues = new ArrayList<>();
String[] queues = getQueueNames();
for (String queue : queues) {
QueueControl coreQueueControl = (QueueControl) managementService.getResource(ResourceNames.QUEUE + queue);
// Ignore the "special" subscription
if (coreQueueControl != null) {
if (durability == DurabilityType.ALL || durability == DurabilityType.DURABLE && coreQueueControl.isDurable() || durability == DurabilityType.NON_DURABLE && !coreQueueControl.isDurable()) {
matchingQueues.add(coreQueueControl);
}
}
}
return matchingQueues;
} catch (Exception e) {
return Collections.emptyList();
}
}
use of org.apache.activemq.artemis.api.core.management.QueueControl in project activemq-artemis by apache.
the class AddressControlImpl method getMessageCount.
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
// Private -------------------------------------------------------
private long getMessageCount(final DurabilityType durability) {
List<QueueControl> queues = getQueues(durability);
long count = 0;
for (QueueControl queue : queues) {
count += queue.getMessageCount();
}
return count;
}
use of org.apache.activemq.artemis.api.core.management.QueueControl in project activemq-artemis by apache.
the class BasicXaRecoveryTest method checkQueueDeliveryCount.
private void checkQueueDeliveryCount(SimpleString thequeue, int expectedCount) throws Exception {
QueueControl queueControl = ManagementControlHelper.createQueueControl(thequeue, thequeue, mbeanServer);
int actualCount = queueControl.getDeliveringCount();
assertEquals(expectedCount, actualCount);
}
use of org.apache.activemq.artemis.api.core.management.QueueControl in project activemq-artemis by apache.
the class ClusteredMessageCounterTest method testMessageAddedWithPaging.
// messages flow from one node to another, in paging mode
// check the messageAdded is correct.
private void testMessageAddedWithPaging(boolean durable) throws Exception {
startServers(0, 1);
numMsg = 100;
try {
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
createQueue(0, "queues", "queue0", null, false);
createQueue(1, "queues", "queue0", null, false);
waitForBindings(1, "queues", 1, 0, true);
waitForBindings(0, "queues", 1, 0, false);
addConsumer(1, 1, "queue0", null);
waitForBindings(0, "queues", 1, 1, false);
System.out.println("sending.....");
send(0, "queues", numMsg, durable, null);
verifyReceiveAllOnSingleConsumer(true, 0, numMsg, 1);
QueueControl control = (QueueControl) servers[1].getManagementService().getResource(ResourceNames.QUEUE + "queue0");
// wait up to 30sec to allow the counter get updated
long timeout = 30000;
while (timeout > 0 && (numMsg != control.getMessagesAdded())) {
Thread.sleep(1000);
timeout -= 1000;
}
assertEquals(numMsg, control.getMessagesAdded());
} finally {
stopServers(0, 1);
}
}
use of org.apache.activemq.artemis.api.core.management.QueueControl in project activemq-artemis by apache.
the class BridgeReconnectTest method testReconnectSameNode.
// Fail bridge and reconnect same node, no backup specified
@Test
public void testReconnectSameNode() throws Exception {
server0 = createActiveMQServer(0, isNetty(), server0Params);
TransportConfiguration server0tc = new TransportConfiguration(getConnector(), server0Params, "server0tc");
server0.getConfiguration().setConnectorConfigurations(connectors);
server1.getConfiguration().setConnectorConfigurations(connectors);
BridgeConfiguration bridgeConfiguration = createBridgeConfig();
List<BridgeConfiguration> bridgeConfigs = new ArrayList<>();
bridgeConfigs.add(bridgeConfiguration);
server0.getConfiguration().setBridgeConfigurations(bridgeConfigs);
CoreQueueConfiguration queueConfig0 = new CoreQueueConfiguration().setAddress(testAddress).setName(queueName);
List<CoreQueueConfiguration> queueConfigs0 = new ArrayList<>();
queueConfigs0.add(queueConfig0);
server0.getConfiguration().setQueueConfigurations(queueConfigs0);
CoreQueueConfiguration queueConfig1 = new CoreQueueConfiguration().setAddress(forwardAddress).setName(queueName);
List<CoreQueueConfiguration> queueConfigs1 = new ArrayList<>();
queueConfigs1.add(queueConfig1);
server1.getConfiguration().setQueueConfigurations(queueConfigs1);
startServers();
locator = addServerLocator(ActiveMQClient.createServerLocatorWithHA(server0tc, server1tc));
ClientSessionFactory csf0 = locator.createSessionFactory(server0tc);
session0 = csf0.createSession(false, true, true);
ClientSessionFactory csf1 = locator.createSessionFactory(server1tc);
session1 = csf1.createSession(false, true, true);
ClientProducer prod0 = session0.createProducer(testAddress);
ClientConsumer cons1 = session1.createConsumer(queueName);
session1.start();
// Now we will simulate a failure of the bridge connection between server0 and server1
Bridge bridge = server0.getClusterManager().getBridges().get(bridgeName);
assertNotNull(bridge);
RemotingConnection forwardingConnection = getForwardingConnection(bridge);
InVMConnector.failOnCreateConnection = true;
InVMConnector.numberOfFailures = reconnectAttempts - 1;
forwardingConnection.fail(new ActiveMQNotConnectedException());
forwardingConnection = getForwardingConnection(bridge);
forwardingConnection.fail(new ActiveMQNotConnectedException());
final ManagementService managementService = server0.getManagementService();
QueueControl coreQueueControl = (QueueControl) managementService.getResource(ResourceNames.QUEUE + queueName);
assertEquals(0, coreQueueControl.getDeliveringCount());
final int numMessages = NUM_MESSAGES;
SimpleString propKey = new SimpleString("propkey");
for (int i = 0; i < numMessages; i++) {
ClientMessage message = session0.createMessage(false);
message.putIntProperty(propKey, i);
prod0.send(message);
}
for (int i = 0; i < numMessages; i++) {
ClientMessage r1 = cons1.receive(1500);
assertNotNull(r1);
assertEquals(i, r1.getObjectProperty(propKey));
}
closeServers();
assertNoMoreConnections();
}
Aggregations