Scheduling long-running tasks

The default behavior of the scheduler is designed to run business logic that runs for a short period of time. In version 6.0.2 and later, two API methods on the com.ibm.websphere.scheduler.TaskInfo interface help avoid some of the problems that can occur when running tasks for an extended time.

 

About this task

The TaskInfo.setQOS method supports tasks with both a transactional and non-transactional quality of service. When running tasks that run for long periods, we can use the TaskInfo.QOS_ATLEASTONCE quality of service to run the task without a global transaction. This process prevents various timeout issues that can occur when resources are held by a long-running transaction. See Transactions and schedulers for details on the TaskInfo.setQOS method and how it can be used.

Using the TaskInfo.setExpectedDuration method, the scheduler can to adjust timeout values, as appropriate, for a given task for all qualities of service. The application server attempts to adjust various run-time parameters to accommodate the estimated run time of the task.

 

Procedure

  1. When you assemble the TaskInfo object with the Scheduler API or the WASScheduler MBean, use the following methods on the TaskInfo interface:

    1. Set the quality of service.
      1. If the task must be transactional, use the setQOS method with the QOS_ONLYONCE constant, which is the default, if not set.
      2. If the task does not need to be transactional, use the setQOS method with the QOS_ATLEASTONCE constant.
    2. Set the expected duration.
      1. Use the setExpectedDuration method to set the expected duration of the task in seconds.
  2. Schedule the task using the Scheduler.create method.

 

What to do next

Access schedulers.

Related concepts
Transactions and schedulers
Related reference
Reference: Generated API documentation

 



 

 

IBM is a trademark of the IBM Corporation in the United States, other countries, or both.