Package gov.usgs.earthquake.distribution
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 Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addNotificationListener(NotificationListener listener)
Add a NotificationListener.void
receiveNotification(Notification notification)
Receive and process a notification.void
removeExpiredNotifications()
If a NotificationReceiver stores notifications, all expired notifications and products should be removed when this method is called.void
removeNotificationListener(NotificationListener listener)
Remove a NotificationListener.Product
retrieveProduct(ProductId id)
NotificationListeners use this method to request a product.void
sendNotifications(NotificationListener listener, java.util.List<java.lang.String> sources, java.util.List<java.lang.String> types, java.util.List<java.lang.String> codes)
Send matching notifications to the listener.
-
-
-
Method Detail
-
receiveNotification
void receiveNotification(Notification notification) throws java.lang.Exception
Receive and process a notification.- Parameters:
notification
- the notification being received.- Throws:
java.lang.Exception
- if errors occur.
-
removeExpiredNotifications
void removeExpiredNotifications() throws java.lang.Exception
If a NotificationReceiver stores notifications, all expired notifications and products should be removed when this method is called.- Throws:
java.lang.Exception
- if errors occur while removing expired notifications.
-
retrieveProduct
Product retrieveProduct(ProductId id) throws java.lang.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:
java.lang.Exception
- if an error occurs while retrieving the product.
-
addNotificationListener
void addNotificationListener(NotificationListener listener) throws java.lang.Exception
Add a NotificationListener. Notifications processed after this call will be sent to listener.- Parameters:
listener
- the listener to add.- Throws:
java.lang.Exception
- if errors occur.
-
removeNotificationListener
void removeNotificationListener(NotificationListener listener) throws java.lang.Exception
Remove a NotificationListener. Notifications processed after this call will not be sent to listener.- Parameters:
listener
- the listener to remove.- Throws:
java.lang.Exception
- if errors occur.
-
sendNotifications
void sendNotifications(NotificationListener listener, java.util.List<java.lang.String> sources, java.util.List<java.lang.String> types, java.util.List<java.lang.String> codes) throws java.lang.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:
java.lang.Exception
- if errors occur.
-
-