Java batch persistence configuration
Java batch uses a persistent store to persist status, checkpoints, and application persistent data across multiple runs of a job instance. The persistent store enables a job instance to be restarted if an earlier run fails or must be stopped by supplying the restarted job with the appropriate data.
Java batch memory-based persistence configuration
The batch persistence allows a job instance to be restarted if the execution ends in a FAILED or STOPPED state. In the absence of batch persistence configuration, Java batch uses a default capability of memory-based persistence to track status, checkpoints, and application persistent data across multiple runs of a job instance.
The default memory-based persistence implementation for Java batch is used by the underlying batch container when there is no batchPersistence and databaseStore elements present in the server.xml file.
Java batch database persistence configuration
By default, the batch run time auto-creates non-existent tables based on the server configuration defined in the databaseStore element. The table definitions are customized based on the schema and tablePrefix attributes of the database store.
Alternatively, the ddlGen script can be used to generate a DDL based on the server configuration. If necessary, the DDL can be customized before manually creating the tables. This DDL also incorporates server configuration such as schema andtablePrefix and contains the appropriate SQL for the database type of the data source referenced by the databaseStore.
The auto-creation of tables can be disabled by using the createTables="false" attribute on the databaseStore. This option can be used to ensure that you use manually created tables instead of using auto-created tables if the batch runtime unexpectedly might not find your manually created tables.
The following samples use the default auto-create behavior. This behavior is equivalent to createTables="true".
Persistence configuration sample
<!-- Batch persistence config. References a databaseStore. -->
<batchPersistence jobStoreRef="BatchDatabaseStore" />
<!-- The database store for the batch tables. -->
<!-- Note this database store is referenced by the batchPersistence element. -->
<databaseStore id="BatchDatabaseStore" dataSourceRef="batchDB" schema="JBATCH" tablePrefix="" />
<!-- Derby JDBC driver -->
<!-- Note this library is referenced by the dataSource element -->
<library id="DerbyLib">
<fileset dir="${server.config.dir}/resources/derby" />
</library>
<!-- Data source for the batch tables. -->
<!-- Note this data source is referenced by databaseStore element -->
<dataSource id="batchDB" isolationLevel="TRANSACTION_REPEATABLE_READ" >
<jdbcDriver libraryRef="DerbyLib" />
<properties.derby.embedded
databaseName="${server.config.dir}/resources/RUNTIMEDB"
createDatabase="create"
user="user"
password="pass" />
</dataSource>