Class EventPoller<T>
java.lang.Object
com.github.workerframework.util.rabbitmq.EventPoller<T>
- Type Parameters:
T
- the sort of Event this EventPoller will use
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
DefaultRabbitPublisher
,RabbitConsumer
An abstract class to poll a BlockingQueue for events and defer them for handling.
-
Constructor Summary
ConstructorsConstructorDescriptionEventPoller
(int pollPeriod, BlockingQueue<Event<T>> eventQueue, T eventHandler) Create a new EventPoller. -
Method Summary
Modifier and TypeMethodDescriptionprotected final BlockingQueue<Event<T>>
void
run()
Start a thread that will poll with the period specified when the object was created.final void
shutdown()
Signal the termination of the EventPoller.
-
Constructor Details
-
EventPoller
Create a new EventPoller.- Parameters:
pollPeriod
- the period in which to poll the event queue, which will also affect the shutdown timeeventQueue
- the object to use for storing and polling eventseventHandler
- the implementation to handle events
-
-
Method Details
-
run
public void run()Start a thread that will poll with the period specified when the object was created. Each event received will be handed off to the event handler which inheriting classes specify. This thread will properly query and re-raise the interrupt flag. -
getEventQueue
- Returns:
- the internal event queue
-
shutdown
public final void shutdown()Signal the termination of the EventPoller. It will terminate at the next possible opportunity. If the EventPoller is not running this has no effect.
-