Task Execution Listener

Allows a user to register listeners for specific events that occur during the task lifecycle. This is done by creating a class that implements the TaskExecutionListener interface. The class that implements the TaskExecutionListener interface will be notified for the following events:

  1. onTaskStartup - prior to the storing the TaskExecution into the TaskRepository
  2. onTaskEnd - prior to the updating of the TaskExecution entry in the TaskRepository marking the final state of the task.
  3. onTaskFailed - prior to the onTaskEnd method being invoked when an unhandled exception is thrown by the task.

Spring Cloud Task also allows a user add TaskExecution Listeners to methods within a bean by using the following method annotations:

  1. @BeforeTask - prior to the storing the TaskExecution into the TaskRepository
  2. @AfterTask - prior to the updating of the TaskExecution entry in the TaskRepository marking the final state of the task.
  3. @FailedTask - prior to the @AfterTask method being invoked when an unhandled exception is thrown by the task.
 public class MyBean {

	@BeforeTask
	public void methodA(TaskExecution taskExecution) {
	}

	@AfterTask
	public void methodB(TaskExecution taskExecution) {
	}

	@FailedTask
	public void methodC(TaskExecution taskExecution, Throwable throwable) {
	}
}