Network Deployment (Distributed operating systems), v8.0 > Develop and deploying applications > Develop Scheduler service > Scheduling tasks
Submit a task to a scheduler
This topic describes the process of submitting a task to a configured scheduler. This task assumes that we have already configured a scheduler and created and configured a TaskInfo object that calls a session bean or sends a Java Messaging Service (JMS) message.
Once we 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.
Procedure
Create the task. After you configure TaskInfo, submit it to the appropriate scheduler, using the Scheduler API create method.
// 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()”We can also create the task using wsadmin 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 $taskStatusWhen 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.
Tip: The TaskStatus object is only a snapshot of the current state of the task. Use the Scheduler.getStatus() method to receive the current state when needed.
Transactions and schedulers
Asynchronous beans
Develop a task that calls a session bean
Develop a task that sends a JMS message
Configure schedulers
Create a scheduler resource reference