Interface NotificationReceiver

All Superinterfaces:
Configurable
All Known Implementing Classes:
AwsProductReceiver, DefaultNotificationReceiver, EIDSNotificationReceiver, EIDSProductReceiver, NATSStreamingNotificationReceiver, SocketProductReceiver, WebSocketNotificationReceiver

public interface NotificationReceiver extends Configurable
Receives and processes notifications. A NotificationReceiver receives and processes notifications, alerting NotificationListeners after they are processed.
  • Method Details

    • receiveNotification

      void receiveNotification(Notification notification) throws Exception
      Receive and process a notification.
      Parameters:
      notification - the notification being received.
      Throws:
      Exception - if errors occur.
    • removeExpiredNotifications

      void removeExpiredNotifications() throws Exception
      If a NotificationReceiver stores notifications, all expired notifications and products should be removed when this method is called.
      Throws:
      Exception - if errors occur while removing expired notifications.
    • retrieveProduct

      Product retrieveProduct(ProductId id) throws Exception
      NotificationListeners use this method to request a product. A NotificationReceiver may have many listeners, and should try to retrieve products once for each product id. This will typically generate a "local" notification, that, when expiring, signals the product may be removed.
      Parameters:
      id - the product to retrieve.
      Returns:
      the retrieved product, or null if not available.
      Throws:
      Exception - if an error occurs while retrieving the product.
    • addNotificationListener

      void addNotificationListener(NotificationListener listener) throws Exception
      Add a NotificationListener. Notifications processed after this call will be sent to listener.
      Parameters:
      listener - the listener to add.
      Throws:
      Exception - if errors occur.
    • removeNotificationListener

      void removeNotificationListener(NotificationListener listener) throws Exception
      Remove a NotificationListener. Notifications processed after this call will not be sent to listener.
      Parameters:
      listener - the listener to remove.
      Throws:
      Exception - if errors occur.
    • sendNotifications

      void sendNotifications(NotificationListener listener, List<String> sources, List<String> types, List<String> codes) throws Exception
      Send matching notifications to the listener. This method is a way for listeners to search notifications that were processed while not an active listener. If sources, types, and codes are all null, a notifications for each known ProductId will be sent to listener. For example, a new shakemap NotificationListener may wish to know about all known shakemaps.
       NotificationListener shakemapListener;
       // register to receive new notifications as they arrive
       receiver.addNotificationListener(shakemapListener);
       // check if any notifications haven't already been processed.
       List<String> types = new LinkedList<String>();
       types.add("shakemap");
       types.add("shakemap-scenario");
       receiver.sendNotifications(shakemapListener, null, types, null);
       
      Parameters:
      listener - the listener that will receive any matching notifications.
      sources - a list of sources to search, or null for all sources.
      types - a list of types to search, or null for all types.
      codes - a list of codes to search, or null for all codes.
      Throws:
      Exception - if errors occur.