Class ListenerNotifierThread
- java.lang.Object
-
- gov.usgs.earthquake.distribution.roundrobinnotifier.ListenerNotifierThread
-
- All Implemented Interfaces:
java.lang.Runnable
public class ListenerNotifierThread extends java.lang.Object implements java.lang.Runnable
Thread that delivers notifications to a listener. Uses interrupt to stop thread, so listeners should be careful when also using interrupts.
-
-
Constructor Summary
Constructors Constructor Description ListenerNotifierThread(NotificationListener listener)
Create a new listener notifier thread.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.LinkedBlockingQueue<ListenerNotification>
getErrorQueue()
NotificationListener
getListener()
ListenerNotificationQueue
getQueue()
void
notify(NotificationEvent event)
Add a notification to the queue.void
requeueErrors()
Move any failed notifications that are ready to be retried from the error queue into the queue.void
run()
Process notifications in the queue.void
start()
Start processing notifications in the queue.void
stop()
Stop processing notifications in the queue.
-
-
-
Constructor Detail
-
ListenerNotifierThread
public ListenerNotifierThread(NotificationListener listener)
Create a new listener notifier thread.- Parameters:
listener
- listener that receives notifications.
-
-
Method Detail
-
start
public void start()
Start processing notifications in the queue.
-
stop
public void stop()
Stop processing notifications in the queue.
-
run
public void run()
Process notifications in the queue.- Specified by:
run
in interfacejava.lang.Runnable
-
notify
public void notify(NotificationEvent event)
Add a notification to the queue. Checks if notification is "accept"able before queueing.- Parameters:
event
- notification to add.
-
getListener
public NotificationListener getListener()
- Returns:
- the listener.
-
getQueue
public ListenerNotificationQueue getQueue()
- Returns:
- the queue.
-
getErrorQueue
public java.util.concurrent.LinkedBlockingQueue<ListenerNotification> getErrorQueue()
- Returns:
- the error queue.
-
requeueErrors
public void requeueErrors()
Move any failed notifications that are ready to be retried from the error queue into the queue.
-
-