public static void cancelJob ( String jobHandle ) throws NoSuchObjectException { checkNonEmpty ( jobHandle , "jobHandle" ) ; Key key = KeyFactory . createKey ( JobRecord . DATA_STORE_KIND , jobHandle ) ; JobRecord jobRecord = backEnd . queryJob ( key , InflationType . NONE ) ; CancelJobTask cancelJobTask = new CancelJobTask ( key , jobRecord . getQueueSettings ( ) ) ; try { backEnd . enqueue ( cancelJobTask ) ; } catch ( TaskAlreadyExistsException e ) { // OK. Some other thread has already enqueued this task. } }
Sends cancellation request to the root job .