WAS v8.5 > Develop applications > Develop Scheduler service > Develop and schedule tasks

Identify tasks that are currently running

When a task runs, the task database record is locked until the task completes. This topic describes how to determine whether or not a task is running. Prior to version 6.0.2, all tasks ran in a single global transaction. This process not only prevented the task from running more than once successfully, but it also blocked all attempts at reading the state of the task, since each task used read-committed transaction isolation.

There are two methods for determining whether a task is running.

  1. NotificationSink

    A NotificationSink EJB can be set on the task using the setNotificationSink method on the TaskInfo object. The NotificationSink bean can then log the life cycle of the task to a separate database record in a custom table. This would result in a history log of the task that can be queried independently from the scheduler. This solution works for all versions of the scheduler service. See the Receiving Scheduler Notifications topic for details.

  2. Delayed Execution and Uncommitted Read

    In v6.0.2 and later, two behaviors enable the scheduler find and retrieve API methods, such as getTask, getTaskStatus or findTasksByName, to see the current state of the task without blocking. To see the current state of the task, including its uncommitted running state...

  1. Enable read-uncommitted transaction isolation for the scheduler read methods to prevent these methods from blocking while a task is running. To set the default transaction isolation for read methods, see the Configuring scheduler default transaction isolation topic for read operation details.

    If the scheduler database does not support uncommitted reads, such as Oracle, it might not be possible to determine if a task is running unless you use the QOS_ATLEASTONCE quality of service.

  2. Use the TaskInfo.EXECUTION_DELAYEDUPDATE option on the TaskInfo.setTaskExecutionOptions method to force the scheduler to write the TaskStatus.RUNNING state to the task when that task starts running.


Related


Receive scheduler notifications
Configure scheduler default transaction isolation


+

Search Tips   |   Advanced Search