Enum ProcessingMode

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<ProcessingMode>

    public enum ProcessingMode
    extends java.lang.Enum<ProcessingMode>
    Strategy for task processing in the queue.
    Since:
    16.07.2017
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static ProcessingMode valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static ProcessingMode[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • SEPARATE_TRANSACTIONS

        public static final ProcessingMode SEPARATE_TRANSACTIONS
        Task will be processed at least once. Each call to database will be done in separate transaction.

        Should be used when there are external calls (HTTP etc.) in task processor. However, external call must be idempotent. In that mode the task processor might execute the task again if after the successful task processing on client side it will be impossible to delete the task from the queue.

      • WRAP_IN_TRANSACTION

        public static final ProcessingMode WRAP_IN_TRANSACTION
        Task processing wrapped into separate database transaction. Task will be executed exactly once when all requirements met.

        Should be used only when there are no external calls in task processor, and the processor is only call the same database where the tasks are stored. When all requirements are met, there is a guarantee that the task will be processed exactly once. If there are external calls during task processing, the database transaction might be kept open for a long period, and the transaction pool will be exhausted.

      • USE_EXTERNAL_EXECUTOR

        public static final ProcessingMode USE_EXTERNAL_EXECUTOR
        Task will be processed at least ones, asynchronously in given executor QueueConsumer.getExecutor(). Each call to database will be performed in separate transaction.

        That mode requires an additional configuration and external executor management. The benefit of this mode is a higher throughput and capability to set upper limit for task processing speed. This is achieved by the fact that the queue threads are only picking tasks from the database, whilst subsequent task processing is carried out in separate executor.

        This mode should be used when the queue performs long-running operations. If this mode will not be used, then the problem might be solved with increasing the number of queue processing threads, although this also will lead to the increasing database idle polls.

    • Method Detail

      • values

        public static ProcessingMode[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (ProcessingMode c : ProcessingMode.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static ProcessingMode valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null