Maclean Pinto
Maclean Pinto

Reputation: 1135

Is there a finally tasklet in spring batch?

Is there a finally tasklet in spring batch? This task always gets executed regardless of if execution was cancelled, or if a task exceptions out. This is used to do any sort of cleanup.

I am not finding any useful listeners in documentation. Any help will be appreciated.

Upvotes: 0

Views: 291

Answers (1)

Mahmoud Ben Hassine
Mahmoud Ben Hassine

Reputation: 31600

I am not finding any useful listeners in documentation

JobExecutionListener#afterJob is what you are looking for. It is always called, regardless of the job exit status. It is the right place to implement any clean-up code.

Hope this helps.

Upvotes: 1

Related Questions