de.esprit.common.concurrent

## Class ProcessingQueue<T>

- java.lang.Object
- - de.esprit.common.util.DumpableObject
  - - de.esprit.common.log.SimpleLogSupportAdapter
    - - de.esprit.common.concurrent.ProcessingQueue<T>

- All Implemented Interfaces:
    SimpleLogSupport, Dumpable

      public class ProcessingQueue<T>
      extends SimpleLogSupportAdapter

  This class uses a `LinkedBlockingDeque` with an internal attached processing daemon thread. The thread takes entries off the queue and passes them to the `QueueHandler` for processing.
  Author:
    Rainer Buesch

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ProcessingQueue(LogChannel logCh, java.lang.String queueName)`
    `ProcessingQueue(LogChannel logCh, java.lang.String queueName, QueueHandler queueHandler)`
    `ProcessingQueue(LogChannel logCh, java.lang.String queueName, QueueHandler queueHandler, int capacity)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `awaitAllDelivered(long time, java.util.concurrent.TimeUnit unit)` Waits until all current entries of the queue have been delivered and processed.
    `java.lang.String` | `getName()`
    `int` | `put(T entry)` Puts an entry at the end of the queue.
    `int` | `putUrgent(T entry)` Puts an urgent entry on top of the queue.
    `void` | `setHandler(QueueHandler handler)` Sets the `QueueHandler` which processes every entry taken from the queue.
    `void` | `setPutTimeout(int timeoutSeconds)` Defines a timeout for put operations in seconds.
    `void` | `shutdown()` Delivers all entries of the queue and kills the running daemon thread.
    `int` | `size()`

    - ### Methods inherited from class de.esprit.common.log.SimpleLogSupportAdapter

      `getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel`

    - ### Methods inherited from class de.esprit.common.util.DumpableObject

      `configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toDumpString, toString, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ProcessingQueue

          public ProcessingQueue(LogChannel logCh,
                         java.lang.String queueName)

    - #### ProcessingQueue

          public ProcessingQueue(LogChannel logCh,
                         java.lang.String queueName,
                         QueueHandler queueHandler)

    - #### ProcessingQueue

          public ProcessingQueue(LogChannel logCh,
                         java.lang.String queueName,
                         QueueHandler queueHandler,
                         int capacity)

  - ### Method Detail

    - #### getName

          public java.lang.String getName()

    - #### size

          public int size()

    - #### setPutTimeout

          public void setPutTimeout(int timeoutSeconds)

      Defines a timeout for put operations in seconds.

    - #### setHandler

          public void setHandler(QueueHandler handler)

      Sets the `QueueHandler` which processes every entry taken from the queue. Note that the queue starts automatically if the handler is set. It stops, when the handler is set to null or `shutdown()` is called.

    - #### shutdown

          public void shutdown()

      Delivers all entries of the queue and kills the running daemon thread. Note that the `QueueHandler` is nullified on shutdown. Setting a new handler will restart the queue daemon thread.

    - #### putUrgent

          public int putUrgent(T entry)
                        throws java.lang.InterruptedException,
                               java.util.concurrent.TimeoutException

      Puts an urgent entry on top of the queue. This entry bypasses all existing entries.
      Throws:
        `java.util.concurrent.TimeoutException`
        `java.lang.InterruptedException`

    - #### put

          public int put(T entry)
                  throws java.lang.InterruptedException,
                         java.util.concurrent.TimeoutException

      Puts an entry at the end of the queue.
      Throws:
        `java.util.concurrent.TimeoutException`
        `java.lang.InterruptedException`

    - #### awaitAllDelivered

          public void awaitAllDelivered(long time,
                               java.util.concurrent.TimeUnit unit)
                                 throws java.lang.InterruptedException,
                                        java.util.concurrent.TimeoutException

      Waits until all current entries of the queue have been delivered and processed.
      Throws:
        `java.lang.InterruptedException`
        `java.util.concurrent.TimeoutException`

Copyright © 2014 EsprIT-Systems. All Rights Reserved.