use of org.apache.activemq.artemis.api.core.management.CoreNotificationType in project activemq-artemis by apache.
the class ActiveMQServerControlImpl method onNotification.
@Override
public void onNotification(org.apache.activemq.artemis.core.server.management.Notification notification) {
if (!(notification.getType() instanceof CoreNotificationType))
return;
CoreNotificationType type = (CoreNotificationType) notification.getType();
TypedProperties prop = notification.getProperties();
this.broadcaster.sendNotification(new Notification(type.toString(), this, notifSeq.incrementAndGet(), notification.toString()));
}
use of org.apache.activemq.artemis.api.core.management.CoreNotificationType in project activemq-artemis by apache.
the class LocalGroupingHandler method onNotification.
@Override
public void onNotification(final Notification notification) {
if (!(notification.getType() instanceof CoreNotificationType))
return;
if (notification.getType() == CoreNotificationType.BINDING_REMOVED) {
SimpleString clusterName = notification.getProperties().getSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME);
removeGrouping(clusterName);
} else if (notification.getType() == CoreNotificationType.BINDING_ADDED) {
SimpleString clusterName = notification.getProperties().getSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME);
try {
lock.lock();
if (expectedBindings != null) {
if (waitingForBindings) {
if (expectedBindings.remove(clusterName)) {
logger.debug("OnNotification for waitForbindings::Removed clusterName=" + clusterName + " from lis succesffully");
} else {
logger.debug("OnNotification for waitForbindings::Couldn't remove clusterName=" + clusterName + " as it wasn't on the original list");
}
} else {
expectedBindings.add(clusterName);
logger.debug("Notification for waitForbindings::Adding previously known item clusterName=" + clusterName);
}
if (logger.isDebugEnabled()) {
for (SimpleString stillWaiting : expectedBindings) {
logger.debug("Notification for waitForbindings::Still waiting for clusterName=" + stillWaiting);
}
}
if (expectedBindings.size() == 0) {
awaitCondition.signal();
}
}
} finally {
lock.unlock();
}
}
}
use of org.apache.activemq.artemis.api.core.management.CoreNotificationType in project activemq-artemis by apache.
the class ClusteredGroupingTest method testGroupingGroupTimeoutSendRemote.
@Test
public void testGroupingGroupTimeoutSendRemote() throws Exception {
setupServer(0, isFileStorage(), isNetty());
setupServer(1, isFileStorage(), isNetty());
setupServer(2, isFileStorage(), isNetty());
setupClusterConnection("cluster0", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 0, 1, 2);
setupClusterConnection("cluster1", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 1, 0, 2);
setupClusterConnection("cluster2", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 2, 0, 1);
setUpGroupHandler(GroupingHandlerConfiguration.TYPE.LOCAL, 0, -1, 2000, 500);
setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 1);
setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 2);
startServers(0, 1, 2);
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
setupSessionFactory(2, isNetty());
createQueue(0, "queues.testaddress", "queue0", null, false);
createQueue(1, "queues.testaddress", "queue0", null, false);
createQueue(2, "queues.testaddress", "queue0", null, false);
addConsumer(0, 2, "queue0", null);
waitForBindings(0, "queues.testaddress", 1, 0, true);
waitForBindings(1, "queues.testaddress", 1, 0, true);
waitForBindings(2, "queues.testaddress", 1, 1, true);
waitForBindings(0, "queues.testaddress", 2, 1, false);
waitForBindings(1, "queues.testaddress", 2, 1, false);
waitForBindings(2, "queues.testaddress", 2, 0, false);
final CountDownLatch latch = new CountDownLatch(4);
getServer(1).getManagementService().addNotificationListener(new NotificationListener() {
@Override
public void onNotification(Notification notification) {
if (!(notification.getType() instanceof CoreNotificationType))
return;
if (notification.getType() == CoreNotificationType.UNPROPOSAL) {
latch.countDown();
}
}
});
getServer(2).getManagementService().addNotificationListener(new NotificationListener() {
@Override
public void onNotification(Notification notification) {
if (!(notification.getType() instanceof CoreNotificationType))
return;
if (notification.getType() == CoreNotificationType.UNPROPOSAL) {
latch.countDown();
}
}
});
sendWithProperty(2, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id1"));
verifyReceiveAll(10, 0);
sendWithProperty(1, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id2"));
verifyReceiveAll(10, 0);
removeConsumer(0);
assertTrue(latch.await(5, TimeUnit.SECONDS));
addConsumer(0, 1, "queue0", null);
waitForBindings(0, "queues.testaddress", 1, 0, true);
waitForBindings(1, "queues.testaddress", 1, 1, true);
waitForBindings(2, "queues.testaddress", 1, 0, true);
waitForBindings(0, "queues.testaddress", 2, 1, false);
waitForBindings(1, "queues.testaddress", 2, 0, false);
waitForBindings(2, "queues.testaddress", 2, 1, false);
sendWithProperty(2, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id1"));
verifyReceiveAll(10, 0);
sendWithProperty(1, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id2"));
verifyReceiveAll(10, 0);
}
use of org.apache.activemq.artemis.api.core.management.CoreNotificationType in project activemq-artemis by apache.
the class ClusteredGroupingTest method testGroupingGroupTimeoutWithUnproposal.
@Test
public void testGroupingGroupTimeoutWithUnproposal() throws Exception {
setupServer(0, isFileStorage(), isNetty());
setupServer(1, isFileStorage(), isNetty());
setupServer(2, isFileStorage(), isNetty());
setupClusterConnection("cluster0", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 0, 1, 2);
setupClusterConnection("cluster1", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 1, 0, 2);
setupClusterConnection("cluster2", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 2, 0, 1);
setUpGroupHandler(GroupingHandlerConfiguration.TYPE.LOCAL, 0, 2000, 1000, 100);
setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 1, 2000, 1000, 100);
setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 2, 2000, 1000, 100);
startServers(0, 1, 2);
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
setupSessionFactory(2, isNetty());
createQueue(0, "queues.testaddress", "queue0", null, false);
createQueue(1, "queues.testaddress", "queue0", null, false);
createQueue(2, "queues.testaddress", "queue0", null, false);
addConsumer(0, 2, "queue0", null);
waitForBindings(0, "queues.testaddress", 1, 0, true);
waitForBindings(1, "queues.testaddress", 1, 0, true);
waitForBindings(2, "queues.testaddress", 1, 1, true);
waitForBindings(0, "queues.testaddress", 2, 1, false);
waitForBindings(1, "queues.testaddress", 2, 1, false);
waitForBindings(2, "queues.testaddress", 2, 0, false);
final CountDownLatch latch = new CountDownLatch(4);
getServer(1).getManagementService().addNotificationListener(new NotificationListener() {
@Override
public void onNotification(Notification notification) {
if (!(notification.getType() instanceof CoreNotificationType))
return;
if (notification.getType() == CoreNotificationType.UNPROPOSAL) {
latch.countDown();
}
}
});
getServer(2).getManagementService().addNotificationListener(new NotificationListener() {
@Override
public void onNotification(Notification notification) {
if (!(notification.getType() instanceof CoreNotificationType))
return;
if (notification.getType() == CoreNotificationType.UNPROPOSAL) {
latch.countDown();
}
}
});
sendWithProperty(0, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id1"));
verifyReceiveAll(10, 0);
sendWithProperty(0, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id2"));
verifyReceiveAll(10, 0);
QueueImpl queue0Server2 = (QueueImpl) servers[2].locateQueue(SimpleString.toSimpleString("queue0"));
assertEquals(2, queue0Server2.getGroupsUsed().size());
assertTrue(latch.await(5, TimeUnit.SECONDS));
long timeLimit = System.currentTimeMillis() + 5000;
while (timeLimit > System.currentTimeMillis() && queue0Server2.getGroupsUsed().size() != 0) {
Thread.sleep(10);
}
assertEquals("Unproposal should cleanup the queue group as well", 0, queue0Server2.getGroupsUsed().size());
removeConsumer(0);
assertTrue(latch.await(5, TimeUnit.SECONDS));
addConsumer(0, 0, "queue0", null);
waitForBindings(0, "queues.testaddress", 1, 1, true);
waitForBindings(1, "queues.testaddress", 1, 0, true);
waitForBindings(2, "queues.testaddress", 1, 0, true);
waitForBindings(0, "queues.testaddress", 2, 0, false);
waitForBindings(1, "queues.testaddress", 2, 1, false);
waitForBindings(2, "queues.testaddress", 2, 1, false);
sendWithProperty(0, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id1"));
verifyReceiveAll(10, 0);
sendWithProperty(0, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id2"));
verifyReceiveAll(10, 0);
}
use of org.apache.activemq.artemis.api.core.management.CoreNotificationType in project activemq-artemis by apache.
the class RemoteGroupingHandler method onNotification.
@Override
public void onNotification(final Notification notification) {
if (!(notification.getType() instanceof CoreNotificationType))
return;
// removing the groupid if the binding has been removed
if (notification.getType() == CoreNotificationType.BINDING_REMOVED) {
SimpleString clusterName = notification.getProperties().getSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME);
List<SimpleString> list = groupMap.remove(clusterName);
if (list != null) {
for (SimpleString val : list) {
if (val != null) {
responses.remove(val);
}
}
}
}
}
Aggregations