Payara JBatch Overview
- Glassfish 4.1 GA comes bundled with JBatch 1.0, Payara 4.1.151 will be shipped with JBatch 1.0.1 b04 which incorporates all the latest JBatch bug fixes.
- We have extended JBatch to use 5 different persistence managers which allows JBatch to be supported across 5 different databases including: Oracle, PostgreSQL, MySQL, DB2 and Derby.
- We allow for JBatch database table names to be prefixed and suffixed across all database types.
- Automatic database schema creation if JBatch schema objects do not already exist.
- We have extended the asadmin batch runtime options which can also be configured in the DAS console.
JBatch Feature Usage on Payara 4.1.151
In this section, I will demonstrate how to use some of the features discussed above and illustrate JBatch on Payara by providing application screenshots of a running JBatch sample application.
Setting the JBatch JDBC resource
To set the JDBC resource named “jdbc/oracledatasource” to be used by JBatch whereby JBatch tables will be created with the table prefix “p” and table suffix “s” under the schema name “testschema”, execute the following asadmin command:
asadmin set-batch-runtime-configuration --datasourcelookupname jdbc/oracledatasource –schemaname testschema --tableprefix p --tablesuffix s
We can also set the above JBatch Properties in the DAS console as we can see from Figure 1 below.As mentioned earlier, if the JBatch database schema objects do not exist then they will be created the first time a new JBatch application had been deployed and run on Payara. The table prefix, suffix and schema name properties noted above are optional and if one does not specify values for these properties default values are used. For the schema name, the user associated with the JDBC connection pool resource will be used as the default value.Once the relevant JBatch properties above have been set and the JBatch application has been deployed, we can now execute JBatch applications on Payara. I have deployed a sample JBatch applications which can be downloaded from https://github.com/javaee-samples/javaee7-samples and built using maven 3. The payroll JBatch sample application calculates monthly payroll for different employees in a company. Below we can view screenshots from the application running and the relevant JBatch tables created with the specified table prefix and suffix mentioned above.
Figure 1: JBatch Configuration Properties in the DAS console
Figure 2: Payroll JBatch Sample Application Output
Figure 3: JBatch Database Table View in SQLDeveloper
Payara Server 4.1.151 will be released on the 30th January so have fun developing and running your JBatch applications on Payara, you now have a greater choice of databases to persist your JBatch application data to!