長時間実行スケジューラー Enterprise JavaBean (EJB) インターフェースは、 長時間実行ジョブをプログラマチックに実行依頼および操作するために使用します。EJB インターフェースを WebSphere スケジューラーと共に使用して、長時間実行ジョブのカレンダー・ベースの 実行依頼を実行することができます。このセクションでは、WebSphere Application Server の基本スケジューラーを使用して、 長時間実行スケジューラーに長時間実行ジョブを実行依頼する方法について説明します。
// 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()); }
Related concepts
長時間実行スケジューラーに対する
Web サービス・インターフェースおよび EJB インターフェース