Listen to task lifecycle events for logging or monitoring.
public class MonitoringListener implements TaskListener { @Override public void onStart(TaskContext context) { System.out.println("Started: " + context.taskId()); } @Override public void onSuccess(TaskContext context) { System.out.println("Finished: " + context.duration()); } @Override public void onFailure(TaskContext context, Throwable error) { System.err.println("Failed: " + error.getMessage()); } }
Register it in the spec:
SchedulerSpec.builder() .addListener(new MonitoringListener()) .build();
Get a point-in-time snapshot of scheduler health.
SchedulerSnapshot snapshot = scheduler.getSnapshot(); long running = snapshot.runningCount(); long failed = snapshot.failedCount(); long completed = snapshot.completedCount(); System.out.printf("Health: %d running, %d failed%n", running, failed);
There was an error while loading. Please reload this page.