Batch class

The batch class is the class in which tasks are created and provided to a service that executes them. The batch class must implements the interface IBatch. Each method corresponds to a step of the batch life cycle. If an exception is throw into one of these methods, then the method manageFatalError will be called and the batch will be shutdown.

Here is the description of all methods :

  • init(BatchConfiguration configuration)

    Initialization method of the batch. The batch configuration (loading from the configuration file in the automatic mode) can be modified here to change the behavior of the batch.

    Use:
    init JDBC connections pool, read proprietary configuration, sending of a notification mail, ...
  • execute(ITaskExecutor executor)

    Execution method of the batch. Tasks must be given to the executor service at this time. Called one time, or more if the batch is schedule for a number of loop or at fixed period.

    Note:
    the building tasks are of type ITask. Each task must provides an unique identifier to differentiate them.
    Use:
    build of tasks that are provided to the executor service
  • pause()

    Called then the batch execution has been put into waking through the call of the corresponding JMX operation. No more tasks are executed by the executor service.

    Use:
    free connections of the JDBC connections pool,...
  • resume()

    Called then the batch execution has been resumed through the call of the corresponding JMX operation. The executor service takes back the tasks execution.

    Use:
    re-establish the connections of the JDBC connections pool, ...
  • end(ExecutionReport report)

    Called at the end of the batch execution. The execution report contains the start date of the execution, the end date, the number of executed tasks, an iterator over the id of the completed and failed tasks.

    Use:
    destroy of the JDBC connections pool, sending of a report mail, log of the execution report, ...
  • endOfExecution(ITask task, Throwable exception)

    Called after the end of the execution of a task.

    Use:
    log the result of the execution
  • manageFatalError(ExecutionReport report, Throwable throwable)

    Called if a fatal error occurred. In this case, the batch will be stopped just after this call. A fatal error is an exception throws into one of the batch class method.

    Use:
    sending of a notification mail, ...