Interface WorkManager

    • Method Detail

      • schedule

        void schedule​(Work work)
        Schedules work for execution at a later time.

        This method is identical to schedule(Work, boolean) with afterCommit = false.

        Parameters:
        work - the work to execute
      • schedule

        void schedule​(Work work,
                      boolean afterCommit)
        Schedules work for execution at a later time, after the current transaction (if any) has committed.
        Parameters:
        work - the work to execute
        afterCommit - if true and the work is scheduled, it will only be run after the current transaction (if any) has committed
      • schedule

        void schedule​(Work work,
                      WorkManager.Scheduling scheduling,
                      boolean afterCommit)
        Schedules work for execution at a later time, with a specific scheduling policy.
        Parameters:
        work - the work to execute
        scheduling - the scheduling policy
        afterCommit - if true and the work is scheduled, it will only be run after the current transaction (if any) has committed
        See Also:
        schedule(Work)
      • getCategoryQueueId

        String getCategoryQueueId​(String category)
        Gets the queue id used for a given work category.
        Parameters:
        category - the category
        Returns:
        the queue id
      • isProcessingEnabled

        boolean isProcessingEnabled()
        Is processing enabled for at least one queue
        Since:
        8.3
      • supportsProcessingDisabling

        boolean supportsProcessingDisabling()
        Returns:
        true if the implementation supports processing disabling
        Since:
        10.3
      • enableProcessing

        void enableProcessing​(boolean value)
        Set processing for all queues
        Since:
        8.3
      • isProcessingEnabled

        boolean isProcessingEnabled​(String queueId)
        Is processing enabled for a given queue id.
        Since:
        8.3
      • enableProcessing

        void enableProcessing​(String queueId,
                              boolean value)
        Set processing for a given queue id.
        Since:
        8.3
      • isQueuingEnabled

        boolean isQueuingEnabled​(String queueId)
        Is queuing enabled for a given queue id.
        Since:
        8.3
      • shutdownQueue

        boolean shutdownQueue​(String queueId,
                              long timeout,
                              TimeUnit unit)
                       throws InterruptedException
        Shuts down a work queue and attempts to suspend and save the running and scheduled work instances.
        Parameters:
        queueId - the queue id
        timeout - the time to wait
        unit - the timeout unit
        Returns:
        true if shutdown is done, false if there are still some threads executing after the timeout
        Throws:
        InterruptedException
      • shutdown

        boolean shutdown​(long timeout,
                         TimeUnit unit)
                  throws InterruptedException
        Shuts down this WorkManager and attempts to suspend and save the running and scheduled work instances.
        Parameters:
        timeout - the time to wait
        unit - the timeout unit
        Returns:
        true if shutdown is done, false if there are still some threads executing after the timeout
        Throws:
        InterruptedException
      • getQueueSize

        @Deprecated
        int getQueueSize​(String queueId,
                         Work.State state)
        Deprecated.
        since 5.8,
        Gets the number of work instances in a given queue in a defined state.

        Parameters:
        queueId - the queue id
        state - the state defining the state to look into, SCHEDULED, RUNNING, or null for non-completed ( SCHEDULED or RUNNING)
        Returns:
        the number of work instances in the given state
        Since:
        5.8
      • awaitCompletion

        boolean awaitCompletion​(String queueId,
                                long timeout,
                                TimeUnit unit)
                         throws InterruptedException
        Waits for completion of work in a given queue.
        Parameters:
        queueId - the queue id
        timeout - the time to wait
        unit - the timeout unit
        Returns:
        true if all work completed in the queue, or false if there is still some non-completed work after the timeout
        Throws:
        InterruptedException
      • awaitCompletion

        boolean awaitCompletion​(long timeout,
                                TimeUnit unit)
                         throws InterruptedException
        Waits for completion of all work.
        Parameters:
        timeout - the time to wait
        unit - the timeout unit
        Returns:
        true if all work completed, or false if there is still some non-completed work after the timeout
        Throws:
        InterruptedException
      • find

        @Deprecated
        Work find​(String workId,
                  Work.State state)
        Deprecated.
        since 10.2 not scalable
        Finds a work instance.
        Parameters:
        workId - the id of the work to find
        state - the state defining the state to look into, SCHEDULED, RUNNING, or null for non-completed
        Returns:
        the found work instance, or null if not found
        Since:
        7.3
      • listWork

        @Deprecated
        List<WorklistWork​(String queueId,
                            Work.State state)
        Deprecated.
        since 10.2 not scalable
        Lists the work instances in a given queue in a defined state.
        Parameters:
        queueId - the queue id
        state - the state defining the state to look into, SCHEDULED, RUNNING, or null for non-completed
        Returns:
        the list of work instances in the given state
      • listWorkIds

        @Deprecated
        List<StringlistWorkIds​(String queueId,
                                 Work.State state)
        Deprecated.
        since 10.2 not scalable
        Lists the work ids in a given queue in a defined state.
        Parameters:
        queueId - the queue id
        state - the state defining the state to look into, SCHEDULED, RUNNING, or null for non-completed
        Returns:
        the list of work ids in the given state
        Since:
        5.8