Package gov.usgs.earthquake.distribution
Interface NotificationListener
-
- All Superinterfaces:
Configurable
- All Known Implementing Classes:
ContentListener,DefaultNotificationListener,DefaultNotificationSender,DYFIIndexerWedge,EIDSNotificationSender,EIDSOutputWedge,ExternalNotificationListener,FileTrackingListener,HeartbeatListener,Indexer,NATSStreamingNotificationSender,RelayProductListener,ShakeMapIndexerWedge
public interface NotificationListener extends Configurable
Process Notifications of Products. NotificationListeners receive Notifications from NotificationReceivers. First, a listener registers with a NotificationReceiver using the addNotificationListener method:receiver.addNotificationListener(listener);
A listener may "search" previous notifications using the NotificationReceiver's sendNotifications method.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intgetMaxTries()A NotificationReceiver that generates a NotificationEvent will attempt to deliver the event up to this many times, if the listener throws an Exception while processing.longgetTimeout()A NotificationListener has this many milliseconds to process a notification before being interrupted.voidonNotification(NotificationEvent event)Receive a Notification that a product is available.
-
-
-
Method Detail
-
onNotification
void onNotification(NotificationEvent event) throws java.lang.Exception
Receive a Notification that a product is available. If this NotificationListener is interested in the Product, it may use the convenience method getProduct():Product product = event.getProduct();
When getTimeout() returns a positive (>0) number of milliseconds, the thread calling onNotification may be interrupted. Listeners should use care in handling InterruptedExceptions to ensure resources are properly freed.- Parameters:
event- the event corresponding to the notification that is available.- Throws:
ContinuableListenerException- if redelivery should be attempted (depending on what getAttemptCount() returns).java.lang.Exception- See Also:
ContinuableListenerException,InterruptedException,getMaxTries()
-
getMaxTries
int getMaxTries()
A NotificationReceiver that generates a NotificationEvent will attempt to deliver the event up to this many times, if the listener throws an Exception while processing.- Returns:
- A value of 1 or less means do not attempt more than once.
-
getTimeout
long getTimeout()
A NotificationListener has this many milliseconds to process a notification before being interrupted.- Returns:
- number of milliseconds before timing out. A value of 0 or less means never time out.
-
-