Improved Asadmin Commands
The following is a list of the administration commands that have been introduced or changed from GlassFish in Payara Server to improve the JBatch API.
set-batch-runtime-configuration
- Usage
-
asadmin> set-batch-runtime-configuration --datasourcelookupname="jdbc/default" --executorservicelookupname="concurrent/__defaultManagedExecutorService" --schemaName="APP" --tablePrefix="BJP" --tableSuffix="BJS"
- Aim
-
Configures the batch runtime storage and execution settings.
Command Options
Option | Shortcut | Description | Default | Mandatory |
---|---|---|---|---|
|
N/A |
The instance or cluster to configure |
server |
No |
|
-d |
The JNDI name of the JDBC data source used to store job information |
N/A |
Yes (unless |
|
-x |
The JNDI name of the Managed Executor Service that provides threads for the jobs' execution. |
N/A |
Yes (unless |
|
-n |
The database schema that holds the batch tables. |
APP |
No |
|
N/A |
The prefix to apply to the batch table name. |
N/A |
No |
|
N/A |
Sets the suffix to apply to the batch table name. |
N/A |
No |
purge-jbatch-repository
Since Payara Server 4.1.2.173
- Usage
-
asadmin> purge-jbatch-repository <apptag>
- Aim
-
Purges the current JBatch repository of all jobs scheduled for the referenced application’s tag. The application’s tag is structured like this:
<Configuration Identifier>:<Application Name>__/<Application Name>
Where Configuration Identifier is the identifier of the configuration associated to the instance or cluster where the application is deployed and Application Name is the name of the deployed application.
Example
To remove all current jobs for an application named jbatch-test deployed on the
DAS (server-config
) then run the following command:
asadmin > purge-jbatch-repository "server-config:jbatch-test__/jbatch-test"
The command will remove all current jobs created by the referenced application whether these jobs are running or not. |
If you are having trouble finding the application’s tag for your application, you can get it programmatically on a Java EE application by using the following code: |
import com.ibm.jbatch.container.servicesmanager.ServicesManager;
import com.ibm.jbatch.container.servicesmanager.ServicesManagerImpl;
import com.ibm.jbatch.container.services.IPersistenceManagerService;
...
JobOperator jobOperator = getJobOperator();
Long executionId = jobOperator.start("job-name", new Properties());
ServicesManager manager = ServicesManagerImpl.getInstance();
IPersistenceManagerService ps = manager.getPersistenceManagerService();
String applicationTag = ps.getJobCurrentTag(jobid);
You need to add a dependency to IBM’s JBatch runtime to your project to access the classes mentioned:
<dependency>
<groupId>com.ibm.jbatch</groupId>
<artifactId>com.ibm.jbatch-runtime-all</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>