Before you begin
This task assumes that you have already configured a scheduler and created and configured a TaskInfo object that calls a session bean or sends a JMS message.Why and when to perform this task
Once you have developed a TaskInfo object that contains all relevant data for a task, submit the task to a scheduler for creation. When the task is created, the scheduler runs it.
Step for this task
// Create the TaskInfo using the Scheduler that you already looked up and print out the Task ID TaskStatus ts = scheduler.create(taskInfo); System.out.println(“Task created with id: “ + ts.getTaskId()”You can also create the task using the wsadmin tool as shown in the following JACL scripting example:
# Create the TaskInfo using the WASScheduler MBean that you previously located and print out the Task ID puts "Creating the task..." set params [java::new {java.lang.Object[]} 1] $params set 0 $taskInfo set sigs [java::new {java.lang.String[]} 1] $sigs set 0 com.ibm.websphere.scheduler.TaskInfo set taskStatus [java::cast com.ibm.websphere.scheduler.TaskStatus [$AdminControl invoke_jmx $schedO create $params $sigs]] puts "Task Created. TaskID= [$taskStatus getTaskId]" puts $taskStatus
When the call to the create() method is complete, the task exists in the persistent store and is run at the time specified in the TaskInfo object. If a global transactional context is present on the thread, and the create() transaction rolls back or is aborted, the task does not run.
The TaskStatus object, which has been returned by the call to the create() method, contains information about the state of the task, as well as the task ID. The task ID is the unique identifier for this task, and is required if the task is to be suspended, resumed, cancelled, and so on, at a later time.
Related concepts
Transactions and schedulers
Asynchronous beans
Related tasks
Developing a task that calls a session bean
Developing a task that sends a Java Message Service message
Configuring schedulers
Creating a scheduler resource reference