use of org.apache.activemq.artemis.core.server.management.Notification in project activemq-artemis by apache.
the class RemoteGroupingHandler method receive.
@Override
public Response receive(final Proposal proposal, final int distance) throws Exception {
TypedProperties props = new TypedProperties();
props.putSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_GROUP_ID, proposal.getGroupId());
props.putSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_VALUE, proposal.getClusterName());
props.putIntProperty(ManagementHelper.HDR_BINDING_TYPE, BindingType.LOCAL_QUEUE_INDEX);
props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, address);
props.putIntProperty(ManagementHelper.HDR_DISTANCE, distance);
Notification notification = new Notification(null, CoreNotificationType.PROPOSAL, props);
managementService.sendNotification(notification);
return null;
}
use of org.apache.activemq.artemis.core.server.management.Notification in project activemq-artemis by apache.
the class AcceptorControlTest method testNotifications.
@Test
public void testNotifications() throws Exception {
TransportConfiguration acceptorConfig = new TransportConfiguration(InVMAcceptorFactory.class.getName(), new HashMap<String, Object>(), RandomUtil.randomString());
TransportConfiguration acceptorConfig2 = new TransportConfiguration(NettyAcceptorFactory.class.getName(), new HashMap<String, Object>(), RandomUtil.randomString());
Configuration config = createBasicConfig().addAcceptorConfiguration(acceptorConfig).addAcceptorConfiguration(acceptorConfig2);
ActiveMQServer service = createServer(false, config);
service.setMBeanServer(mbeanServer);
service.start();
AcceptorControl acceptorControl = createManagementControl(acceptorConfig2.getName());
SimpleNotificationService.Listener notifListener = new SimpleNotificationService.Listener();
service.getManagementService().addNotificationListener(notifListener);
Assert.assertEquals(0, notifListener.getNotifications().size());
acceptorControl.stop();
Assert.assertEquals(usingCore() ? 5 : 1, notifListener.getNotifications().size());
Notification notif = notifListener.getNotifications().get(usingCore() ? 2 : 0);
Assert.assertEquals(CoreNotificationType.ACCEPTOR_STOPPED, notif.getType());
Assert.assertEquals(NettyAcceptorFactory.class.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("factory")).toString());
acceptorControl.start();
Assert.assertEquals(usingCore() ? 10 : 2, notifListener.getNotifications().size());
notif = notifListener.getNotifications().get(usingCore() ? 7 : 1);
Assert.assertEquals(CoreNotificationType.ACCEPTOR_STARTED, notif.getType());
Assert.assertEquals(NettyAcceptorFactory.class.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("factory")).toString());
}
use of org.apache.activemq.artemis.core.server.management.Notification in project activemq-artemis by apache.
the class ClusterConnectionControlTest method getFirstNotificationOfType.
private Notification getFirstNotificationOfType(List<Notification> notifications, CoreNotificationType type) {
Notification result = null;
// the notifications can change while we're looping
List<Notification> notificationsClone = new ArrayList<>(notifications);
for (Notification notification : notificationsClone) {
if (notification.getType().equals(type)) {
result = notification;
}
}
return result;
}
use of org.apache.activemq.artemis.core.server.management.Notification in project activemq-artemis by apache.
the class BridgeControlTest method testNotifications.
@Test
public void testNotifications() throws Exception {
SimpleNotificationService.Listener notifListener = new SimpleNotificationService.Listener();
BridgeControl bridgeControl = createBridgeControl(bridgeConfig.getName(), mbeanServer);
server_0.getManagementService().addNotificationListener(notifListener);
Assert.assertEquals(0, notifListener.getNotifications().size());
bridgeControl.stop();
Assert.assertEquals(1, notifListener.getNotifications().size());
Notification notif = notifListener.getNotifications().get(0);
Assert.assertEquals(CoreNotificationType.BRIDGE_STOPPED, notif.getType());
Assert.assertEquals(bridgeControl.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString());
bridgeControl.start();
Assert.assertEquals(2, notifListener.getNotifications().size());
notif = notifListener.getNotifications().get(1);
Assert.assertEquals(CoreNotificationType.BRIDGE_STARTED, notif.getType());
Assert.assertEquals(bridgeControl.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString());
}
use of org.apache.activemq.artemis.core.server.management.Notification in project activemq-artemis by apache.
the class DiscoveryTest method testDiscoveryGroupNotifications.
@Test
public void testDiscoveryGroupNotifications() throws Exception {
SimpleNotificationService notifService = new SimpleNotificationService();
SimpleNotificationService.Listener notifListener = new SimpleNotificationService.Listener();
notifService.addNotificationListener(notifListener);
final InetAddress groupAddress = InetAddress.getByName(address1);
final int groupPort = getUDPDiscoveryPort();
final int timeout = 500;
dg = newDiscoveryGroup(RandomUtil.randomString(), RandomUtil.randomString(), null, groupAddress, groupPort, timeout, notifService);
Assert.assertEquals(0, notifListener.getNotifications().size());
dg.start();
Assert.assertEquals(1, notifListener.getNotifications().size());
Notification notif = notifListener.getNotifications().get(0);
Assert.assertEquals(CoreNotificationType.DISCOVERY_GROUP_STARTED, notif.getType());
Assert.assertEquals(dg.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString());
dg.stop();
Assert.assertEquals(2, notifListener.getNotifications().size());
notif = notifListener.getNotifications().get(1);
Assert.assertEquals(CoreNotificationType.DISCOVERY_GROUP_STOPPED, notif.getType());
Assert.assertEquals(dg.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString());
}
Aggregations