requestTermination
- requestTermination()
The requestTermination method is a no-argument class method.
Whenever you click the Stop button on the Server Tools Batch Process Info screen, PolicyCenter calls the requestTermination method on that batch process to terminate the batch process, if possible.
Your custom batch process must shut down
any necessary systems and stop your batch process if you receive this
message. If you cannot terminate your batch process, return false from this method.
The BatchProcessBase
class implementation of the requestTermination
method always returns false,
which means that the request did not succeed. The base class also sets
an internal TerminateRequested
flag that you can check to see if a terminate request was received.
For typical implementations, use the following pattern:
- Override the requestTermination method and
have it return
true. Whenever a user requests termination of the batch process, PolicyCenter calls your overridden version of the method. - Ensure that the doWork method in your custom class
frequently checks the value of the
TerminateRequestedflag. In yourdoWorkcode, exit from your code if that flag is set. For example, if you are looping across a database query, exit from the loop and return.
Override the requestTermination
method and return false
if you genuinely cannot terminate the process soon. Be warned that if
you do this, you risk the server shutting down before your process completes.
false from
requestTermination, Guidewire strongly recommends you design your
batch process so that you actually can terminate the action. It is critical to
understand that returning either value does not prevent the application from shutting
down or reducing run level. PolicyCenter delays shutdown
or change in run level for a period of time. However, eventually the application shuts
down or reduces run level independent of this batch process setting. For maximum
reliability and data integrity, design your code to frequently check and respect the
TerminateRequested property.PolicyCenter writes a line to the application log to indicate whether it is possible to terminate the batch process. In other words, the log line includes the result of your requestTermination method.
If your batch process can only run one
instance at a time, returning true
does not remove the batch process from the internal table of running
batch processes. This means that another instance cannot run until the
previous one completes.
