org.apache.activemq.artemis.core.server.management.Notification类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(11.8k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中org.apache.activemq.artemis.core.server.management.Notification类的一些代码示例,展示了Notification类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Notification类的具体详情如下:
包路径:org.apache.activemq.artemis.core.server.management.Notification
类名称:Notification

Notification介绍

[英]A Notification
[中]通知

代码示例

代码示例来源:origin: wildfly/wildfly

@Override
public synchronized void start() throws Exception {
 if (started) {
   return;
 }
 endpoint.openClient();
 started = true;
 thread = new Thread(new DiscoveryRunnable(), "activemq-discovery-group-thread-" + name);
 thread.setDaemon(true);
 thread.start();
 if (notificationService != null) {
   TypedProperties props = new TypedProperties();
   props.putSimpleStringProperty(new SimpleString("name"), new SimpleString(name));
   Notification notification = new Notification(nodeID, CoreNotificationType.DISCOVERY_GROUP_STARTED, props);
   notificationService.sendNotification(notification);
 }
}

代码示例来源:origin: apache/activemq-artemis

@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);
        }
      }
     }
   }
  }
}

代码示例来源:origin: apache/activemq-artemis

private void sendNotification(JMSNotificationType type, String message) {
 TypedProperties prop = new TypedProperties();
 prop.putSimpleStringProperty(JMSNotificationType.MESSAGE, SimpleString.toSimpleString(message));
 Notification notif = new Notification(null, type, prop);
 try {
   server.getManagementService().sendNotification(notif);
 } catch (Exception e) {
   ActiveMQJMSServerLogger.LOGGER.failedToSendNotification(notif.toString());
 }
}

代码示例来源:origin: apache/activemq-artemis

@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()));
}

代码示例来源:origin: apache/activemq-artemis

notificationMessage.setAddress(managementNotificationAddress);
if (notification.getProperties() != null) {
 TypedProperties props = notification.getProperties();
 props.forEach(notificationMessage::putObjectProperty);
notificationMessage.putStringProperty(ManagementHelper.HDR_NOTIFICATION_TYPE, new SimpleString(notification.getType().toString()));
if (notification.getUID() != null) {
 notificationMessage.putStringProperty(new SimpleString("foobar"), new SimpleString(notification.getUID()));

代码示例来源:origin: apache/activemq-artemis

@Override
  public void onNotification(Notification notification) {
   if (!(notification.getType() instanceof CoreNotificationType))
     return;
   if (notification.getType() == CoreNotificationType.UNPROPOSAL) {
     latch.countDown();
   }
  }
});

代码示例来源:origin: apache/activemq-artemis

@Test
public void testNotifications() throws Exception {
 SimpleNotificationService.Listener notifListener = new SimpleNotificationService.Listener();
 checkResource(ObjectNameBuilder.DEFAULT.getClusterConnectionObjectName(clusterConnectionConfig1.getName()));
 ClusterConnectionControl clusterConnectionControl = createManagementControl(clusterConnectionConfig1.getName());
 server_0.getManagementService().addNotificationListener(notifListener);
 Assert.assertEquals(0, notifListener.getNotifications().size());
 clusterConnectionControl.stop();
 Assert.assertTrue(notifListener.getNotifications().size() > 0);
 Notification notif = getFirstNotificationOfType(notifListener.getNotifications(), CoreNotificationType.CLUSTER_CONNECTION_STOPPED);
 Assert.assertNotNull(notif);
 Assert.assertEquals(clusterConnectionControl.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString());
 clusterConnectionControl.start();
 Assert.assertTrue(notifListener.getNotifications().size() > 0);
 notif = getFirstNotificationOfType(notifListener.getNotifications(), CoreNotificationType.CLUSTER_CONNECTION_STARTED);
 Assert.assertNotNull(notif);
 Assert.assertEquals(clusterConnectionControl.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString());
}

代码示例来源:origin: apache/activemq-artemis

@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();

代码示例来源:origin: apache/activemq-artemis

@Override
  public void onNotification(Notification notification) {
   if (!(notification.getType() instanceof CoreNotificationType))
     return;
   if (notification.getType() == CoreNotificationType.UNPROPOSAL) {
     latch.countDown();
   }
  }
});

代码示例来源:origin: apache/activemq-artemis

codesAsked.add(notification.getProperties().getSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_GROUP_ID));

代码示例来源:origin: wildfly/wildfly

TypedProperties props = new TypedProperties();
props.putSimpleStringProperty(new SimpleString("name"), new SimpleString(name));
Notification notification = new Notification(nodeID, CoreNotificationType.DISCOVERY_GROUP_STOPPED, props);
try {
 notificationService.sendNotification(notification);

代码示例来源:origin: apache/activemq-artemis

@Override
public void onNotification(final Notification notification) {
 if (!(notification.getType() instanceof CoreNotificationType))
   return;
   CoreNotificationType type = (CoreNotificationType) notification.getType();
      TypedProperties props = notification.getProperties();
      TypedProperties props = notification.getProperties();
      TypedProperties props = notification.getProperties();
      TypedProperties props = notification.getProperties();

代码示例来源:origin: apache/activemq-artemis

@Override
  public void onNotification(Notification notification) {
   if (!(notification.getType() instanceof CoreNotificationType))
     return;
   if (notification.getType() == CoreNotificationType.UNPROPOSAL) {
     latch.countDown();
   }
  }
});

代码示例来源:origin: apache/activemq-artemis

private void sendConnectionNotification(final RemotingConnection connection, final CoreNotificationType type) {
 final ManagementService managementService = getManagementService();
 if (managementService != null && sendConnectionNotifications) {
   try {
    final TypedProperties props = new TypedProperties();
    props.putSimpleStringProperty(ManagementHelper.HDR_CONNECTION_NAME, SimpleString.toSimpleString(connection.getID().toString()));
    props.putSimpleStringProperty(ManagementHelper.HDR_REMOTE_ADDRESS, SimpleString.toSimpleString(connection.getRemoteAddress()));
    managementService.sendNotification(new Notification(null, type, props));
   } catch (Exception e) {
    logger.warn("Error sending notification: " + type, e.getMessage(), e);
   }
 }
}

代码示例来源:origin: apache/activemq-artemis

@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());
}

代码示例来源:origin: apache/activemq-artemis

@Override
  public void onNotification(Notification notification) {
   if (!(notification.getType() instanceof CoreNotificationType))
     return;
   if (notification.getType() == CoreNotificationType.UNPROPOSAL) {
     latch.countDown();
   }
  }
});

代码示例来源:origin: apache/activemq-artemis

@Override
public synchronized void start() throws Exception {
 if (started) {
   return;
 }
 endpoint.openClient();
 started = true;
 thread = new Thread(new DiscoveryRunnable(), "activemq-discovery-group-thread-" + name);
 thread.setDaemon(true);
 thread.start();
 if (notificationService != null) {
   TypedProperties props = new TypedProperties();
   props.putSimpleStringProperty(new SimpleString("name"), new SimpleString(name));
   Notification notification = new Notification(nodeID, CoreNotificationType.DISCOVERY_GROUP_STARTED, props);
   notificationService.sendNotification(notification);
 }
}

代码示例来源:origin: apache/activemq-artemis

@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());
}

代码示例来源:origin: apache/activemq-artemis

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;
}

代码示例来源:origin: apache/activemq-artemis

@Override
public synchronized void start() throws Exception {
 if (started) {
   return;
 }
 endpoint.openClient();
 started = true;
 thread = new Thread(new DiscoveryRunnable(), "activemq-discovery-group-thread-" + name);
 thread.setDaemon(true);
 thread.start();
 if (notificationService != null) {
   TypedProperties props = new TypedProperties();
   props.putSimpleStringProperty(new SimpleString("name"), new SimpleString(name));
   Notification notification = new Notification(nodeID, CoreNotificationType.DISCOVERY_GROUP_STARTED, props);
   notificationService.sendNotification(notification);
 }
}

相关文章

微信公众号

最新文章

更多