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>

public abstract class BatchPublisher<T> extends Object implements Publisher<T>
Generic publisher that will queue anything for batch processing.
  • Constructor Details

    • BatchPublisher

      public BatchPublisher(String name, BatchPublisherConfiguration configuration)
      This constructs the thread pool of worker threads. The pool is not executed until startup().
      Parameters:
      name - Name given to the thread pool worker threads.
      configuration - queue management and thread pool configuration settings.
  • Method Details

    • startupPublisher

      protected abstract void startupPublisher() throws ResourceException
      This is invoked by startup(). 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

      protected abstract void shutdownPublisher() throws ResourceException
      This is invoked by shutdown(). 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

      protected abstract void publishMessages(List<T> messages)
      This is invoked by the worker threads to have the passed in messages published immediately.
      Parameters:
      messages - the messages to publish immediately.
    • startup

      public final void startup() throws ResourceException
      This first initializes the worker threads that monitor the queue of items to publish, and then calls startupPublisher().
      Specified by:
      startup in interface Publisher<T>
      Throws:
      ResourceException - If there is trouble starting up the publisher or starting the worker threads.
    • shutdown

      public final void shutdown() throws ResourceException
      This shutdowns the worker threads, and then calls shutdownPublisher().
      Specified by:
      shutdown in interface Publisher<T>
      Throws:
      ResourceException - if there is trouble shutting down the publisher or stopping the worker threads.
    • publish

      public final void publish(T message)
      Offers the message to the queue. If the offer isn't accepted for 1 minute, the message is lost.
      Specified by:
      publish in interface Publisher<T>
      Parameters:
      message - the message to queue.