21 Configuring Partition Batch Job Runtime

This chapter describes how to configure the batch runtime in WebLogic Server partitions. You can use either the WLS Administration Console or WLST to configure a partition-level batch job runtime, as described in this chapter.

Configuring Partition Batch Runtime: Overview

Batch jobs are tasks that can be executed without user interaction and are best suited for non-interactive, bulk-oriented and long-running tasks that are resource intensive, can execute sequentially or in parallel, and may be initiated ad hoc or through scheduling.

WebLogic Server supports batch runtimes that are scoped to partitions. Using the batch runtime in partitions requires the configuration of a dedicated data source for each partition to access the JobRepository tables for batch jobs. When a Java EE component deployed to the partition submits a batch job, the batch runtime updates the JobRepository tables using this data source.

Optionally, a partition batch runtime can be configured 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 JobRepository data source stores the status of current and past jobs. However, if no MES template is targeted to the partition, the batch 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).

For detailed information about configuring and managing batch runtime for a domain scope, such as the steps for creating the JobRepository tables, see "Configuring the Batch Runtime" in Administering Server Environments for Oracle WebLogic Server.

For detailed 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.

Configuring Partition Batch Runtime: Steps

In order to configure a batch runtime in a partition, you must complete these steps:

  • If necessary, create the JobRepository tables to store the batch jobs.

  • Configure a JDBC data source for the partition.

  • Optionally, create a MES template and target it to the partition.

  • Configure the partition batch runtime using either the WLS Administration Console or WLST.

Prerequisites

In order to configure a batch runtime in a partition, the following prerequisites must be completed at the domain level:

  • JobRepository tables must already exist—The batch runtime does not create JobRepository tables automatically. The DB administrator must create the tables prior to activating the partition.

    For information on configuring JobRepository tables, see "Configuring the Batch Runtime" in Administering Server Environments for Oracle WebLogic Server.

    For information about the databases supported for containing the JobRepository 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 PartitionMBean.setBatchJobsDataSourceJndiName. When a Java EE component submits a batch job, the batch runtime updates the JobRepository tables using this data source, which is obtained by looking up the data source's JNDI name.

    For instructions on configuring a JDBC data source, see "Creating a JDBC Data Source" in Administering JDBC Data Sources for Oracle WebLogic Server.

  • Optionally, create a MES template—For optimum performance, the batch runtime in a partition can be configured 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 will then run batch jobs that are submitted for Java EE components that are deployed to the partition.

    However, if no name is set, then the batch runtime will use the default Java EE MES that is bound to the default JNDI name of: java:comp/DefaultManagedExecutorService.

    For information on configuring a MES template, see "Global CMO Templates" in Administering Server Environments for Oracle WebLogic Server.

Configuring Partition Batch Runtime Using the WLS Administration Console

A dedicated batch runtime can be configured per partition using the WLS Administration Console. In the Settings for partition-name page, open the Configuration > General page for the partition and complete these configuration fields:

  • Executor Service Template—The name of the application-scoped MES instance that will be used to run batch jobs that are submitted from applications deployed to the partition.

    A 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 runtime will use 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 runtime's data source, which will be 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 runtime updates the batch JobRepository tables using this data source, which is obtained by looking up the data source's JNDI name.

Configuring Partition Batch Runtime: WLST Example

A dedicated batch runtime can be configured per partition using WLST.

You can use WLST with the BatchRuntimeConfigMBean and PartitionMBean to configure the batch runtime to use a specific database for the JobRepository:

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') will configure the batch runtime to store all the JobRepository tables in the schema 'BATCH' in the database that is pointed by the data source that is bound to the jndiName: 'jdbc/batchDS'.

You can use WLST to configure the batch runtime to use a specific MES for batch job execution. However, you must first create an 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()

where mesName is the name of the MES template that has already been created (and targeted) to this partition.

The batch runtime can be configured to use different MESs using the getBatchJobsManagedExecutorServiceName() method in the PartitionMBean. However, a MES template by the same name must exist and be scoped to the partition when a batch job is submitted.

For more information, 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.

Querying the Batch Runtime

The batch runtime's JobRepository can be queried per partition scope using these administrative tools:

Note:

Make sure that the database that contains the batch JobRepository is running. For example, the default Derby database is not automatically started when you boot WebLogic Server using the java weblogic.Server command. If your database is not running, an exception will be thrown by the Batch RI when you submit a batch job or when you access the BatchJobRepositoryRuntimeMBean, either through WLST or the WLS Administration Console.

Using the WLS Administration Console to Query the Batch Runtime

A JobRepository can be queried using the WLS Administration Console to obtain details about batch jobs in a partition.

Get Details of All Batch Jobs

In the Settings for partition-name page, open the Monitoring > Batch Jobs page to view details about all the jobs submitted by applications deployed to the partition.

Table 21-1 All Batch Jobs

Element Name Description

Job Name

The name of the batch job.

Application Name

The name of the application that submitted the batch job.

Instance ID

The instance ID.

Execution ID

The execution ID.

Batch Status

The batch status of this job.

Start Time

The start time of the job.

End Time

The completion time of the job.

Exit Status

The exit status of the job.


Get Details About a Job's Execution

You can view step execution details about a job by selecting it and clicking View.

Table 21-2 Job Executions Details

Element Name Description

Job Name

The name of the batch job.

Instance ID

The instance ID.

Execution ID

The execution ID.

Batch Status

The batch status of this job.

Start Time

The start time of the job.

End Time

The completion time of the job.

Exit Status

The exit status of the job.


Get Details About a Job's Step Execution

You can view metrics about each step in a job execution by selecting it and clicking View.

Table 21-3 Step Executions Details

Element Name Description

Step Name

The name of the batch job step.

Step ID

The step ID.

Execution ID

The execution ID.

Batch Status

The batch status of this job.

Start Time

The start time of the job.

End Time

The completion time of the job.

Exit Status

The exit status of the job.


Using Runtime MBeans to Query the Batch Runtime

The JobRepository can be queried using WLST using the BatchJobRepositoryRuntimeMBean to obtain details about batch jobs in a partition.

For more information, see BatchJobRepositoryRuntimeMBean in the MBean Reference for Oracle WebLogic Server.

Get Details of All Batch Jobs Using getJobDetails

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 following elements:

Table 21-4 Elements in getJobDetails() Attribute

Element Name Description

JOB_NAME

The name of the batch job.

APP_NAME

The name of the application that submitted the batch job (String).

INSTANCE_ID

The instance ID (long).

EXECUTION_ID

The execution ID (long).

BATCH_STATUS

The batch status of this job (String).

START_TIME

The start time of the job (java.util.Date).

END_TIME

The completion time of the job (java.util.Date).

EXIT_STATUS

The exit status of the job (String).


Here is an example of a WLST script that uses getJobDetails() 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]

Here 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

Get Details of a Job Execution Using getJobExecutions

The getJobExections attribute returns details about a particular job execution. Each entry in the collection contains an array of the following elements:

Table 21-5 Elements in getJobExecutions() Attribute

Element Name Description

JOB_NAME

The name of the batch job (String).

INSTANCE_ID

The instance ID (long).

EXECUTION_ID

The execution ID (long).

BATCH_STATUS

The batch status of this job (String).

START_TIME

The start time of the job (java.util.Date).

END_TIME

The completion time of the job (java.util.Date).

EXIT_STATUS

The exit status of the job (String).


Here is an example of using getJobExectuions() in a WLST script to get details for a given ExecutionID: getJobExecutions(6). To get a list of all ExecutionIDs, 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]

Here 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

Get Details of a Job Step Execution Using getStepExecutions

The getStepExecutions attribute returns metrics about each step in a job execution. Each entry in the collection contains an array of the following elements:

Table 21-6 Elements in getStepExecutions() Attribute

Element Name Description

STEP_NAME

The name of the batch job step (String).

STEP_ID

The step ID (long).

EXECUTION_ID

The execution ID (long).

BATCH_STATUS

The batch status of this job (String).

START_TIME

The start time of the job (java.util.Date).

END_TIME

The completion time of the job (java.util.Date).

EXIT_STATUS

The exit status of the job (String).


Here is an example of 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], "]

Here 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 Partition Batch Runtime: Related Tasks and Links

See the following sections for additional information: