Batch jobs are tasks that can be executed without user interaction and are best suited for non-interactive, bulk-oriented, long-running tasks that are resource intensive. They can execute sequentially or in parallel, and may be initiated dynamically or through scheduling. WebLogic Server supports batch job runtimes that are scoped to partitions.
This chapter includes the following sections:
Using the batch job runtime in partitions requires the configuration of a dedicated data source for each partition to access the job repository tables for batch jobs. When a Java EE component deployed to the partition submits a batch job, the batch job runtime updates the job repository tables using this data source.
Optionally, you can configure a partition batch job runtime to use an application-scoped Managed Executor Service (MES) by configuring MES templates at the domain level, but which are scoped to partitions. The MES processes the jobs asynchronously and the job repository data source stores the status of current and past jobs. However, if no MES template is targeted to the partition, the batch job runtime will use the MES that is bound to the default JNDI name of java:comp/DefaultManagedExecutorService
(as required by the Java EE 7 specification).
WebLogic Server also supports the use of multiple batch runtime instances within the scope of a partition. However, there are important considerations to note with regards to the deployment of a batch application that is replicated in multiple Managed Server instances, in either clustered or nonclustered environments, and also with regards to load balancing and the ability to restart failed batch jobs. See Use of Multiple Batch Runtime Instances in Administering Server Environments for Oracle WebLogic Server, and Batch Applications in Administering Clusters for Oracle WebLogic Server.
For more information about configuring and managing batch job runtime for a domain scope, such as the steps for creating the job repository tables, and important considerations for the use of multiple batch runtime instances, see Configuring the Batch Job Runtime in Administering Server Environments for Oracle WebLogic Server.
For more information about batch jobs, batch processing, and the batch processing framework, see Batch Processing in The Java EE 7 Tutorial. Also see the Java Specification Request 352: Batch Applications for the Java Platform (http://jcp.org/en/jsr/detail?id=352
). The specification defines the programming model for batch applications and the runtime for scheduling and executing batch jobs.
To configure a batch job runtime in a partition, you must complete certain steps.
If necessary, create the job repository tables to store the batch jobs.
Configure a JDBC data source for the partition.
Optionally, create the MES template and target it to the partition.
Configure the partition batch job runtime using either the WebLogic Server Administration Console or WLST.
To configure a batch job runtime in a partition, the following prerequisites must be completed at the domain level:
Job repository tables must already exist. The batch job runtime does not create job repository tables automatically. The database administrator must create the tables prior to activating the partition.
For information about configuring job repository tables, see Configuring the Batch Job Runtime in Administering Server Environments for Oracle WebLogic Server.
For information about the databases supported for containing the job repository tables, see the Oracle Fusion Middleware Supported System Configurations page on the Oracle Technology Network.
Configure a JDBC data source for the partition. Each partition must have a dedicated JDBC data source created for batch jobs. The batch data source's JNDI name must be set using the PartitionMBean.setBatchJobsDataSourceJndiName
. When a Java EE component submits a batch job, the batch job runtime updates the job repository tables using this data source, which is obtained by looking up the data source's JNDI name.
For more information about configuring a JDBC data source, see Creating a JDBC Data Source in Administering JDBC Data Sources for Oracle WebLogic Server.
Optionally, create the MES template. For optimum performance, you can configure the batch job runtime in a partition to use an application-scoped MES by configuring MES templates at the domain level, but which are scoped to partitions. This way, a new MES instance is created for each MES template, which then runs batch jobs that are submitted for Java EE components that are deployed to the partition.
However, if no name is set, then the batch job runtime uses the default Java EE MES that is bound to the default JNDI name of: java:comp/DefaultManagedExecutorService
.
For information about configuring the MES template, see Global CMO Templates in Administering Server Environments for Oracle WebLogic Server.
You can configure a dedicated batch job runtime per partition using the WebLogic Server Administration Console. In the Settings for partition-name page, go to the Configuration > General page for the partition and complete these configuration fields:
Executor Service Template: The name of the application-scoped MES instance that is used to run batch jobs that are submitted from applications deployed to the partition.
The MES template by the same name must exist and be scoped to the partition when a batch job is submitted to the partition. If no name is set, then the batch job runtime uses the default Java EE MES that is bound to the default JNDI name of: java:comp/DefaultManagedExecutorService
.
Data Source JNDI Name: The JNDI name of the batch job runtime's data source, which is used to store data for batch jobs submitted from applications deployed to the partition. When a Java EE component submits a batch job, the batch job runtime updates the batch job repository tables using this data source, which is obtained by looking up the data source's JNDI name.
You can configure a dedicated batch job runtime per partition using WLST.
You can use WLST with the BatchRuntimeConfigMBean
and PartitionMBean
to configure the batch job runtime to use a specific database for the job repository:
def update_partition_batch_config(partitionName, jndiName, schemaName): connect('admin','passwd') edit() startEdit() cd('/Partitions/' + <partitionName>) cmo.setDataSourceJndiName(jndiName) cd('/BatchConfig/') cmo.setSchemaName(schemaName) save() activate()
In this example, if the administrator has created a data source with the JNDI name jdbc/batchDS
, then calling update_partition_batch_config('<partitionName>','jdbc/batchDS','BATCH')
configures the batch job runtime to store all the job repository tables in the schema 'BATCH'
in the database that is pointed to by the data source that is bound to the jndiName
: 'jdbc/batchDS'
.
You can use WLST to configure the batch job runtime to use a specific MES for batch job execution. However, you must first create the MES template at the domain level and the name of the MES must be provided to the PartitionMBean
.
connect('admin','passwd') edit() startEdit() cd('/Partitions'/ + <partitionName>) cmo.setBatchJobsExecutorServiceName('mesName') save() activate()
mesName
is the name of the MES template that has already been created (and targeted) to this partition.
You can configure the batch job runtime to use different MESs using the getBatchJobsManagedExecutorServiceName()
method in the PartitionMBean
. However, the MES template by the same name must exist and be scoped to the partition when a batch job is submitted.
See the BatchConfigMBean and the PartitionMBean in the MBean Reference for Oracle WebLogic Server.
For more information about using WLST commands, see WebLogic Server WLST Online and Offline Command Reference in the WLST Command Reference for WebLogic Server.
You can query the batch job runtime's job repository table per partition scope using the WebLogic Server Administration Console and Runtime MBeans.
Note:
Ensure that the database that contains the batch job repository is running. For example, the default Derby database is not automatically started when you start WebLogic Server using the java weblogic.Server
command. If your database is not running, an exception will be thrown when you submit a batch job or when you access the BatchJobRepositoryRuntimeMBean
, either through WLST or the WebLogic Server Administration Console.
You can query a job repository table using the WebLogic Server Administration Console to obtain details about batch jobs in a partition.
In the Settings for partition-name page, go to the Monitoring > Batch Jobs page to view details about all the jobs submitted by applications deployed to the partition. See Table 20-1.
Table 20-1 All Batch Jobs
Element Name | Description |
---|---|
|
The name of the batch job. |
|
The name of the application that submitted the batch job. |
|
The instance ID. |
|
The execution ID. |
|
The batch status of this job. |
|
The start time of the job. |
|
The completion time of the job. |
|
The exit status of the job. |
You can view step execution details about a job by selecting it and clicking View. See Table 20-2.
Table 20-2 Job Executions Details
Element Name | Description |
---|---|
|
The name of the batch job. |
|
The instance ID. |
|
The execution ID. |
|
The batch status of this job. |
|
The start time of the job. |
|
The completion time of the job. |
|
The exit status of the job. |
You can view metrics about each step in a job execution by selecting it and clicking View. See Table 20-3.
Table 20-3 Step Executions Details
Element Name | Description |
---|---|
|
The name of the batch job step. |
|
The step ID. |
|
The execution ID. |
|
The batch status of this job. |
|
The start time of the job. |
|
The completion time of the job. |
|
The exit status of the job. |
You can query the job repository table using WLST using the BatchJobRepositoryRuntimeMBean
to obtain details about batch jobs in a partition.
See BatchJobRepositoryRuntimeMBean in the MBean Reference for Oracle WebLogic Server.
The getJobDetails()
attribute returns details about all the jobs submitted by applications deployed to the domain. Each entry in the collection contains an array of the elements in Table 20-4.
Table 20-4 Elements in getJobDetails() Attribute
Element Name | Description |
---|---|
|
The name of the batch job. |
|
The name of the application that submitted the batch job ( |
|
The instance ID ( |
|
The execution ID ( |
|
The batch status of this job ( |
|
The start time of the job ( |
|
The completion time of the job ( |
|
The exit status of the job ( |
The following example of a WLST script uses the getJobDetails()
command to print a list of all batch jobs deployed in a domain:
connect('admin', 'admin123')
domainRuntime()
cd('BatchJobRepositoryRuntime')
cd('myserver')
executions=cmo.getJobDetails()
print "JobName AppName InstanceID ExecutionID BatchStatus StartTime EndTime ExitStatus"
print e[0], " ", e[1], " ", e[2], " ", e[3], " ", e[4], " ", e[5], " ", e[6], ",e[7]
This is sample output after running getJobDetails()
:
JobName AppName InstanceID ExecutionID BatchStatus StartTime EndTime ExitStatus PayrollJob lab1 9 9 COMPLETED Fri Apr 24 10:11:00 PDT 2015 Fri Apr 24 10:11:01 PDT 2015 COMPLETED PayrollJob lab1 8 8 COMPLETED Fri Apr 24 10:11:00 PDT 2015 Fri Apr 24 10:11:01 PDT 2015 COMPLETED PayrollJob lab1 7 7 COMPLETED Fri Apr 24 10:11:00 PDT 2015 Fri Apr 24 10:11:01 PDT 2015 COMPLETED PayrollJob lab1 6 6 COMPLETED Fri Apr 24 10:11:00 PDT 2015 Fri Apr 24 10:11:01 PDT 2015 COMPLETED PayrollJob lab1 5 5 COMPLETED Fri Apr 24 10:10:57 PDT 2015 Fri Apr 24 10:10:58 PDT 2015 COMPLETED PayrollJob lab1 4 4 COMPLETED Fri Apr 24 10:10:56 PDT 2015 Fri Apr 24 10:10:56 PDT 2015 COMPLETED PayrollJob lab1 3 3 COMPLETED Mon Apr 20 11:32:12 PDT 2015 Mon Apr 20 11:32:12 PDT 2015 COMPLETED PayrollJob lab1 2 2 COMPLETED Mon Apr 20 11:32:10 PDT 2015 Mon Apr 20 11:32:11 PDT 2015 COMPLETED PayrollJob lab1 1 1 COMPLETED Mon Apr 20 11:25:26 PDT 2015 Mon Apr 20 11:25:26 PDT 2015 COMPLETED
The getJobExecutions
attribute returns details about a particular job execution. Each entry in the collection contains an array of the elements in Table 20-5.
Table 20-5 Elements in getJobExecutions() Attribute
Element Name | Description |
---|---|
|
The name of the batch job ( |
|
The instance ID ( |
|
The execution ID ( |
|
The batch status of this job ( |
|
The start time of the job ( |
|
The completion time of the job ( |
|
The exit status of the job ( |
The following example uses the getJobExecutions()
command in a WLST script to get details for a given execution ID: getJobExecutions(6)
. To get a list of all execution IDs, use the getJobDetails()
method:
connect('admin', 'admin123')
partitionRuntime()
cd('BatchJobRepositoryRuntime')
cd('myserver')
executions=cmo.getJobExecutions(6)
print "JobName InstanceID ExecutionID BatchStatus StartTime EndTime ExitStatus"
for e in executions
print e[0], " ", e[1], " ", e[2], " ", e[3], " ", e[4], " ", e[5], " ", e[6]
This is sample output after running getJobExecutions()
:
JobName InstanceID ExecutionID BatchStatus StartTime EndTime ExitStatus PayrollJob 6 6 COMPLETED Fri Apr 24 10:11:00 PDT 2015 Fri Apr 24 10:11:01 PDT 2015 COMPLETED
The getStepExecutions
attribute returns metrics about each step in a job execution. Each entry in the collection contains an array of the elements in Table 20-6.
Table 20-6 Elements in getStepExecutions() Attribute
Element Name | Description |
---|---|
|
The name of the batch job step ( |
|
The step ID ( |
|
The execution ID ( |
|
The batch status of this job ( |
|
The start time of the job ( |
|
The completion time of the job ( |
|
The exit status of the job ( |
The following example shows using getStepExecutions()
in a WLST script to get details for a given step execution ID: getStepExecutions(6)
. To get a list of all execution IDs, use the getJobDetails()
method.
connect('admin', 'admin123')
partitionRuntime()
cd('BatchJobRepositoryRuntime')
cd('myserver')
executions=cmo.getStepExecutions(6)
print "StepName StepExecutionID BatchStatus StartTime EndTime ExitStatus"
print e[0], " ", e[1], " ", e[2], " ", e[3], " ", e[4], " ", e[5], "]
This is sample output after running getStepExecutions()
:
StepName StepExecutionID BatchStatus StartTime EndTime ExitStatus PayrollJob 6 6 COMPLETED Fri Apr 24 10:11:00 PDT 2015 Fri Apr 24 10:11:01 PDT 2015 COMPLETED
Configuring the Batch Job Runtime in Administering Server Environments for Oracle WebLogic Server.
For information about configuring a Managed Executor Service Template, see Global CMO Templates in Administering Server Environments for Oracle WebLogic Server.
For more information about configuring a JDBC data source, see Creating a JDBC Data Source in Administering JDBC Data Sources for Oracle WebLogic Server.
For more information about batch-related configuration and runtime MBeans, see the BatchConfigMBean, BatchJobRepositoryRuntimeMBean, and the PartitionMBean in the MBean Reference for Oracle WebLogic Server.
For more information about using WLST commands, see WebLogic Server WLST Online and Offline Command Reference in the WLST Command Reference for WebLogic Server.
Sample Applications and Code Examples in Understanding Oracle WebLogic Server.
Java Specification Request 352: Batch Applications for the Java Platform (http://jcp.org/en/jsr/detail?id=352
).