OpenWGA 7.9 - TMLScript reference

JobContext
Method :

breakIfCancelled()

On object JobContext
Usage Queries if the job has been cancelled and, if so, cancels it via error
Description

Use this method to make your TMLScript/Java job cancelable. Insert calls to it in your job code where a clean cancellation is possible. If the admin cancels the job via admin client this call will throw an error which cancels the job.

If you use this inside a try/catch block you should ensure that this exception passes it in an unmodified way.  You can do this to check in TMLScript that the thrown error is a Java exception of type "de.innovationgate.wgpublisher.scheduler.JobCancelledException" (see examples).

If you need to perform some special operation in the case of a cancellation you can alternatively (or additionally) check for a cancellation using property cancelled.

Allowed in script types
  • TMLScript tasks in jobs
Examples

This is the example of a cancellable job. Note how the try/catch block tests for cancel errors and just throws them on.

try {


  while ( .... ) {

    jobContext.breakIfCancelled();

    ....

  }


}

catch (error) {

  if (error.javaException and error.javaException instanceof Packages.de.innovationgate.wgpublisher.scheduler.JobCancelledException) {

    throw error;

  }

}