The long-running scheduler Enterprise
JavaBeans (EJB) interface is used to programmatically submit and manipulate
a long-running job. The EJB interface can
be used in conjunction with the base scheduler in WebSphere Application Server
to perform calendar-based submission of a long-running job.
This section describes how to submit a long-running job to
the long-running scheduler using the base
scheduler in WebSphere Application Server.
Procedure
- Create and configure a scheduler. See the Developing and scheduling tasks for information on
how to create and configure a scheduler.
- Create a scheduler task for submitting grid work. This scheduler
task invokes the long-running scheduler EJB
to submit a long-running job. See the Developing a task that calls a session bean topic
in the WebSphere Application Server Version 6.0 information center for instructions
for creating a task that invokes an EJB. This topic also includes instructions
for using the calendaring feature of the WebSphere scheduler. The following
is a task code example on how to invoke the long-running scheduler EJB:
// These are the import statements needed by the Task
import javax.naming.*;
import com.ibm.websphere.longrun.JobScheduler;
import com.ibm.websphere.longrun.JobSchedulerHome
private JobSchedulerHome zjsHome = null;
private JobScheduler zjs = null;
public void process(TaskStatus task) ()
try{
//ensure that the xJCL can be placed in a String, eg: by reading an xJCL
//file into a String.
String xJCL = <xJCL as a string>;
//obtain cell level naming Context
InitialContext ctxt = new InitialContext();
Hashtable env = new Hashtable();
env.put (Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
env.put(Context.PROVIDER_URL,"corbaloc:rir:/NameServiceCellRoot");
ctxt = new InitialContext(env);
//in order to lookup the LRS EJB from the cell context in the namespace,
//the name context to the application server or cluster to which the LRS
//application is deployed has to be provided.
//Eg: "nodes/myNode/servers/myServer" or "clusters/myCluster".
String longRunningContext = <long_running_context>;
zjsHome = (JobSchedulerHome) ctxt.lookup(longRunningContext +
"/ejb/com/ibm/websphere/longrun/JobSchedulerHome");
zjs = zjsHome.create();
zjs.submitJob( xJCL );
}catch (Exception e) {
System.out.println(e.getMessage());
}
- Schedule the scheduler task for submitting grid work. See the Submitting a task to a scheduler documentation in
the WebSphere Application Server Version 6.0 information center.