20 Configuring Partition Batch Job Runtime

This chapter describes how to configure the batch job runtime in Oracle WebLogic Server Multitenant (MT) partitions. You can use either the Oracle WebLogic Server Administration Console or WebLogic Scripting Tool (WLST) to configure a partition-level batch job runtime, as described in this chapter.

Configuring Partition Batch Job 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 dynamically or through scheduling.

WebLogic Server supports batch job runtimes that are scoped to partitions. 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).

For more information about configuring and managing batch job runtime for a domain scope, such as the steps for creating the job repository tables, 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.

Configuring Partition Batch Job Runtime: Main Steps

To configure a batch job runtime in a partition, you must complete these 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.

Prerequisites

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.

Configuring Partition Batch Job Runtime Using the Administration Console

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.

Configuring Partition Batch Job Runtime: WLST Example

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.

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 Job Runtime

You can query the batch job runtime's job repository table per partition scope using these administrative tools:

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.

Using the Administration Console to Query the Batch Job Runtime

You can query a job repository table using the WebLogic Server Administration Console to obtain details about batch jobs in a partition.

Get Details of All Batch Jobs

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. For more information, see Table 20-1.


Table 20-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. For more information, see Table 20-2.


Table 20-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. For more information, see Table 20-3.


Table 20-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 Job Runtime

You can query the job repository table 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 elements in Table 20-4.


Table 20-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).


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

Get Details of a Job Execution Using getJobExecutions

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

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).


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

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 elements in Table 20-6.


Table 20-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).


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

See the following for additional information: