Package org.forgerock.audit.handlers.jms
Class BatchPublisher<T>
java.lang.Object
org.forgerock.audit.handlers.jms.BatchPublisher<T>
- Type Parameters:
T
- This is the type of object that will be queued before publishing.
- All Implemented Interfaces:
Publisher<T>
Generic publisher that will queue anything for batch processing.
-
Constructor Summary
ConstructorsConstructorDescriptionBatchPublisher
(String name, BatchPublisherConfiguration configuration) This constructs the thread pool of worker threads. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
Offers the message to the queue.protected abstract void
publishMessages
(List<T> messages) This is invoked by the worker threads to have the passed in messages published immediately.final void
shutdown()
This shutdowns the worker threads, and then callsshutdownPublisher()
.protected abstract void
This is invoked byshutdown()
.final void
startup()
This first initializes the worker threads that monitor the queue of items to publish, and then callsstartupPublisher()
.protected abstract void
This is invoked bystartup()
.
-
Constructor Details
-
BatchPublisher
This constructs the thread pool of worker threads. The pool is not executed untilstartup()
.- Parameters:
name
- Name given to the thread pool worker threads.configuration
- queue management and thread pool configuration settings.
-
-
Method Details
-
startupPublisher
This is invoked bystartup()
. This should be implemented to initialize any resources that need to be started when the publisher is started. For example, opening shared connections to remote services.- Throws:
ResourceException
- if there is trouble starting the publisher.
-
shutdownPublisher
This is invoked byshutdown()
. This should be implemented to clean up any resources that were initialized in startup. For exmaple, closing the connections to remote services.- Throws:
ResourceException
- if there is trouble shutting down the publisher.
-
publishMessages
This is invoked by the worker threads to have the passed in messages published immediately.- Parameters:
messages
- the messages to publish immediately.
-
startup
This first initializes the worker threads that monitor the queue of items to publish, and then callsstartupPublisher()
.- Specified by:
startup
in interfacePublisher<T>
- Throws:
ResourceException
- If there is trouble starting up the publisher or starting the worker threads.
-
shutdown
This shutdowns the worker threads, and then callsshutdownPublisher()
.- Specified by:
shutdown
in interfacePublisher<T>
- Throws:
ResourceException
- if there is trouble shutting down the publisher or stopping the worker threads.
-
publish
Offers the message to the queue. If the offer isn't accepted for 1 minute, the message is lost.
-