2.3.3 Forcefully stopping a batch application
You can stop a running batch application as and when required. This is called Forced Stop of a batch application. This subsection describes Forced Stop of a batch application.
- Organization of this subsection
(1) How to forcefully stop a batch application
You use the cjkilljob command to forcefully stop a batch application. You use the following three methods to execute the cjkilljob command:
-
Method to directly execute the cjkilljob command
You execute the command by using this method if you do not want to use JP1/AJS.
-
Method to define the cjkilljob command as a recovery job of JP1/AJS and to execute with extension of forced stop of a job or a jobnet
You execute the command by using this method when using JP1/AJS irrespective of the usage status of BJEX or JP1/Advanced Shell.
For details on the definition of JP1/AJS job when forcefully stopping a batch application as a recovery job of JP1/AJS with method 2, see 2.13 Integrating with JP1/AJS.
-
Method for forcefully stopping a batch application by extending forced stop of BJEX or JP1/Advanced Shell
If you execute a batch application by using BJEX or JP1/Advanced Shell, the batch application executed with these products is also automatically stopped when BJEX or JP1/Advanced Shell is forcefully stopped. You do not need to define recovery jobs of JP1/AJS in this method.
Note that if an attempt to forcefully stop a batch application fails, the batch server is forcefully stopped. As a result, when executing multiple applications in continuation, you must restart the batch server. We recommend that you tperform settings in advance, in such a way so that the batch server automatically restarts, when an attempt to forcefully stop the batch application fails. You can implement automatic restart of a batch sever by using operation monitoring of Management Server. For details, see 2.4. Automatically Restart When a Failure Occurs in the uCosminexus Application Server Operation, Monitoring, and Linkage Guide.
(2) Processing of forced stop of a batch application
You use the cjkilljob command to forcefully stop a running batch application. When using the cjkilljob command, you execute the method cancellation for the thread that executes the batch application, and forcefully stop the batch application.
The method cancellation is a functionality that cancels the running methods. However, you may or may not cancel a method, depending on the area where you are executing the method. The area where you can cancel a method is called a non-protected area and the area where you cannot cancel a method is called a protected area. A method is canceled if the method under execution is in a non-protected area. The same method cancellation is performed during the forced stop of a batch application that is performed by the functionality of monitoring the J2EE application execution time. For details on the method cancellation processing, see 5.3.4 Method Cancellation in the uCosminexus Application Server Operation, Monitoring, and Linkage Guide.
The following processes are executed when you forcefully stop a batch application.
-
Output a message (KDJE55004-I) stating that the processing to forcefully stop a batch application starts.
-
Execute the method cancellation for the public static void main(String[]) method or the public static int main(String[]) method.
If an attempt to cancel a method fails, an attempt to execute forced stop fails, KDJE55017-E is output, and the batch server forcefully stops. If an attempt to execute forced stop fails, restart the batch server.
-
Output a message (KDJE55005-I) stating that the processing of forcefully stopping the batch application is complete.
-
Perform Full GC.
-
Send the end code of batch application to the cjexecjob command.
The following table describes the conditions where a batch application is forcefully stopped:
Condition for forced stop of batch application |
Batch server operation |
cjexecjob command operation |
---|---|---|
Batch forced stop command is executed during the execution of a batch application. |
Outputs KDJE55004-I message and starts forced stop of the batch application. Outputs KDJE55005-I message when forced stop is complete. Outputs KDJE55017-E message, if an attempt to execute forced stop fails. |
Normal path when performing batch forced termination Return value: 1 |
If you execute a batch application by using the adshjava command of JP1/Advanced Shell, JP1/Advanced Shell automatically executes the cjkilljob command and forcefully stops the batch application when you forcefully stop a job of JP1/Advanced Shell.
(3) Points to be considered when forcefully stopping a batch application
If an attempt to forcefully stop a batch application fails, the batch server is forcefully stopped. When executing multiple batch applications in continuation, you must restart the batch server before starting a batch application that is to be executed after forcefully stopping the batch server. Hence, set up in such a way so that the batch server automatically restarts by using Management Server. For details, see 5.3.4 Method Cancellation in the uCosminexus Application Server Operation, Monitoring, and Linkage Guide.