使用作业调度程序 EJB 接口提交批处理作业

作业调度程序 Enterprise JavaBeans (EJB) 接口用于通过编程方式提交和处理批处理作业。可以将 EJB 接口与 WebSphere® Application Server 中的基本调度程序配合使用,以执行批处理作业基于日历的提交。

开始之前

作业调度程序支持以编程方式访问其功能,访问既可以通过 Java™ Platform, Enterprise Edition (Java EE) 应用程序的 EJB 接口进行,也可以通过用于 Java EE 和非 Java EE 应用程序的 Web Service 接口进行。API 文档中的接口描述了作业调度程序的 EJB 接口。请参阅此文档以获取更多信息。

开发并安装您的批处理应用程序。

关于此任务

本主题描述如何使用基本调度程序将批处理作业提交到作业调度程序。它还包括一个演示如何调用作业调度程序 EJB 的代码示例。

过程

  1. 创建和配置调度程序。请参阅“开发和调度任务”主题中关于如何创建和配置调度程序的信息。
  2. 创建用于提交批处理工作的调度程序任务。

    此调度程序任务将调用作业调度程序 EJB 来提交批处理作业。请参阅“开发调用会话 Bean 的任务”主题中有关创建调用 EJB 的任务的指示信息。!!!此主题还包含有关使用调度程序日程确定功能的指示信息。以下示例演示如何调用作业调度程序 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, for example, 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);
    
         //To look up 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());
    }
  3. 运行该程序以提交批处理工作。

    请参阅有关将任务提交到调度程序的主题。


指示主题类型的图标 任务主题



时间戳记图标 最近一次更新时间: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=tgrid_xdbgusweb
文件名:tgrid_xdbgusweb.html