Sundial icon indicating copy to clipboard operation
Sundial copied to clipboard

Ineffective JobInterruptException

Open franckvallee opened this issue 6 years ago • 0 comments

Form a simple discovery test, I've created a Job managed programmatically because I aim at having a console to drive execution batchs by users.

Then in main:

        // Manage my job programmatically
        SundialJobScheduler.addJob( HelloJob.jobName(), HelloJob.class.getName());
        // Run my job every 2 seconds and unlimitedly
        SundialJobScheduler.addSimpleTrigger( 
                HelloJob.jobName() + "-Trigger", HelloJob.jobName(), -1, TimeUnit.SECONDS.toMillis(2));

In HelloJob.java:

  @Override
   public void doRun() throws JobInterruptException {
       
       System.out.println( String.format( "Hello Job %d at [%s]", ++count, DF.format( new Date())));
       if ( count >= 3 ) {
           System.out.println( "interrupted by itself");
           //SundialJobScheduler.removeTrigger( jobName() + "-Trigger");
           //SundialJobScheduler.stopJob( jobName()); // ineffective call
           throw new JobInterruptException(); // ineffective
       }
   }

Throwing JobInterruptException was hoping to trigger some behavior at monitor level, but nothing happened. Just wonder the utility of this exception then...

franckvallee avatar Apr 21 '19 05:04 franckvallee